//Imzee Ajax Tabs
//var this_domain = document.domain;
//if (this_domain.indexOf("192.") > -1) this_domain = this_domain + "/wp";


// To Show border of table in brandnames.php page - FA
/*if(document.URL.indexOf("brandnames.php") >-1)    
	var loadstatustext2="<table width=100% cellspacing=0 cellpadding=8><tr><td valign=top align=center class=bodytext><br><br><br><br><b>Loading ...</b><br><br><img src='http://" + this_domain + "/ajax/loading.gif'/></td></tr></table>"
else	                                          // loading table for Index page without border
	var loadstatustext2="<table class=typestable width=100% border=0 cellspacing=0 cellpadding=8><tr><td valign=top><span class=bodytext><b>Loading ...</b></span><br><br><img src='http://" + this_domain + "/ajax/loading.gif'/></td></tr></table>"
*/
var bustcachevar=1 //bust potential caching of external pages after initial request? (1=yes, 0=no)
var loadstatustext="<table class=contenttable width=100% border=0 cellspacing=0 cellpadding=8><tr><td valign=top><span class=bodytext><b>Loading ...</b></span><br><br><img src='ajax/loading.gif' /> </td></tr></table>"

var loadstatustext_loginpanel="<table width=100% border=0 cellspacing=0 cellpadding=8><tr><td valign=top><span class=bodytext><b>Loading ...</b></span><br><br><img src=http://"+this_domain+"/_site/images/loading2.gif ></td></tr></table>"
//var loadstatustext_loginpanel2="<table width=100% border=0 cellspacing=0 cellpadding=8><tr><td valign=top><span class=bodytext><b>Loading ...</b></span><br><br><img src='ajax/loading.gif' /> </td></tr></table>"
//alert(<?php print "'".DIR_WS_IMAGES."'"; ?>);


////NO NEED TO EDIT BELOW////////////////////////


function loadsubdiv(containerid, url){
	var page_request = false
//	var containerid = 'ajaxcontentarea';
	
	//if((url=='body/home/login_box/loginpanel.php') || (url=='ajax/login_box/forgotpw.php'))
	$("#buyselltypesarea").html(loadstatustext_loginpanel);

	var ullist=document.getElementsByTagName("li");
	for (var i=0; i<ullist.length; i++)
	{
		//alert(ullist[i].className);
		if(ullist[i].className == 'loginbox_selected' || ullist[i].className == 'middleimg')
		{
			ullist[i].className=""  //deselect all tabs
		}
	}
	
	
	if(url.indexOf('loginpanel.php') > 0)
	{
		tabunselect();
		//document.getElementById("buyselltypesarea").innerHTML = document.getElementById("loginpanel").innerHTML;
	}
	
	

	if(url == 'forgotpw')
	{
		tabunselect();
		//document.getElementById("buyselltypesarea").innerHTML = document.getElementById("forgotpw_div").innerHTML;
	}



	
	if(url.indexOf('buyers.php') > 0)
	{
	
		//document.getElementById("buyselltypesarea").innerHTML = document.getElementById("buyer_div").innerHTML;
		document.getElementById("buyer").className="loginbox_selected";  //highlight currently clicked on tab
	}
	

	if(url.indexOf('sellers.php') > 0)
	{
		//document.getElementById("buyselltypesarea").innerHTML = document.getElementById("supplier_div").innerHTML;
		document.getElementById("supplier").className="loginbox_selected";  //highlight currently clicked on tab
		
		 
		
		
	}

	if(url.indexOf('aff.php') > 0)
	{
		//document.getElementById("buyselltypesarea").innerHTML = document.getElementById("affiliate_div").innerHTML;
		document.getElementById("affiliate").className="loginbox_selected";  //highlight currently clicked on tab
	}
	
	$.get(url, {}, 
	function(str) 
	{
		$("#buyselltypesarea").html(str);
	}); 

	
	
	/*if (window.XMLHttpRequest) // if Mozilla, Safari etc
		page_request = new XMLHttpRequest();
	else if (window.ActiveXObject)
	{ // if IE
		try 
		{
			page_request = new ActiveXObject("Msxml2.XMLHTTP");
		} 	
		catch (e)
		{
			try
			{
				page_request = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e){}
		}
	}
	else
	return false

	if (containerid == "typesarea")
		document.getElementById(containerid).innerHTML=loadstatustext2;
	else if (containerid == "buyselltypesarea")
		document.getElementById(containerid).innerHTML=loadstatustext_loginpanel;
	else
		document.getElementById(containerid).innerHTML=loadstatustext;

	page_request.onreadystatechange=function(){
		loadpage(page_request, containerid);
		
	}
	if (bustcachevar) //if bust caching of external page
		bustcacheparameter=(url.indexOf("?")!=-1)? "&"+new Date().getTime() : "?"+new Date().getTime();
		
		
		
	
	page_request.open('GET', url+bustcacheparameter, true);
	page_request.send(null);*/
}

// FA - Function to unselect a tab when login link is clicked
function loadpage(page_request, containerid){

	if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1))
	document.getElementById(containerid).innerHTML = page_request.responseText
}

function load_buyer_content()
{

	document.getElementById("buyselltypesarea").innerHTML = document.getElementById("buyer_div").innerHTML;
}


function tabunselect()
{
	var ullist=document.getElementsByTagName("li")
	for (var i=0; i<ullist.length; i++)
	{
		if(ullist[i].id=="sel")
		{
			ullist[i].className=""
		}
	}
}



