// JavaScript Document
var intId;
var divID;
var innerDIV;
var optDIV1;
function bgDiv(opt)
{
	if(screen.width<1025)
	{
		bgImg="images/banner1000.jpg";
		bodyWidth="1000px";
	}
	else if(screen.width<1153)
	{
		bgImg="images/banner1100.jpg";
		bodyWidth="1100px";
	}
	else if(screen.width<1281)
	{
		bgImg="images/banner1250.jpg";
		bodyWidth="1250px";
	}
	else if(screen.width<1401)
	{
		bgImg="images/banner1375.jpg";
		bodyWidth="1375px";
	}
	else 
	{
		bgImg="images/banner1400.jpg";
		bodyWidth="1400px";
	}
	document.getElementById("banner").style.backgroundImage="url("+bgImg+")";
	document.getElementById("body_div").style.width=bodyWidth;
	bodyHeight=screen.height;
	if(opt==3)
	{
		show_div('3','0','');
	}
}

function popup1()
{
	popup();
	close_div('menu1');
}
function popup()
{
	var foo=null;
	if((foo==null) || (foo.closed))
	{	
		foo = window.open("chat/index.php",'chatWin','someOptions');
		foo.moveTo(0,0);
		foo.resizeTo(screen.availWidth,screen.availHeight);
		foo.focus();
	}
	else
	{
		foo.focus();
	}
}

function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    {
    c_start=c_start + c_name.length+1;
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));
    }
  }
return "";
}

function show_div(optDIV, pageid, path) 
{ 
	var scrolledX, scrolledY; 
	intId=pageid;
	optDIV1=optDIV;
	if( self.pageYOffset ) 
	{ 
		scrolledX = self.pageXOffset; 
		scrolledY = self.pageYOffset; 
	} 
	else if( document.documentElement && document.documentElement.scrollTop ) 
	{ 
		scrolledX = document.documentElement.scrollLeft; 
		scrolledY = document.documentElement.scrollTop; 
	} 
	else if( document.body ) 
	{ 
		scrolledX = document.body.scrollLeft; 
		scrolledY = document.body.scrollTop; 
	}

// Next, determine the coordinates of the center of browser's window
	var centerX, centerY; 
	if( self.innerHeight ) 
	{ 
		centerX = self.innerWidth; 
		centerY = self.innerHeight; 
	} 
	else if( document.documentElement && document.documentElement.clientHeight ) 
	{ 
		centerX = document.documentElement.clientWidth; 
		centerY = document.documentElement.clientHeight; 
	} 
	else if( document.body ) 
	{ 
		centerX = document.body.clientWidth; 
		centerY = document.body.clientHeight; 
	}

// Xwidth is the width of the div, Yheight is the height of the 
// div passed as arguments to the function: 
	document.getElementById('menu_detail').style.padding="5px";
	if((optDIV==1)||(optDIV==3))
	{
		var leftOffset = scrolledX + (centerX - 600) / 2; 
		var topOffset = scrolledY + (centerY - 400) / 2;
		divWidth=600;
		divHeight=400;
	}
	if(optDIV==2)
	{
		var leftOffset = scrolledX + (centerX - 320) / 2; 
		var topOffset = scrolledY + (centerY - 170) / 2 - 100; 
		divWidth=320;
		divHeight=170;
	}
	
// The initial width and height of the div can be set in the 
// style sheet with display:none; divid is passed as an argument to // the function 
	document.getElementById('menu_detail').innerHTML ="";
	document.getElementById('menu_detail').style.background="url(images/process.gif) no-repeat center white";
	document.getElementById('menu_detail').style.height=(divHeight-28)+'px';
	
	var o=document.getElementById('menu1'); 
	var r=o.style;
	r.width=divWidth+'px';
	r.height=divHeight+'px';
	r.top = topOffset+'px'; 
	r.left = leftOffset+'px';
	var strUrl;
	
	if(optDIV==1)
	{
		switch(intId)
		{
			case '1':
			case '2':
			case '3':
			case '4':
			case '5':
			case '6':
				strUrl = path+"ajax/bankpage.php";
				break;
			case '7':
			case '8':
			case '9':
			case '10':
			case '11':
			case '12':
			case '13':
			case '14':
			case '15':
			case '17':
			case '18':
			case '19':
			case '20':			
				strUrl = path+"ajax/cmspage.php?page_id="+intId;
				break;
		}
		r.display = "block"; 
		xmlhttpPost(strUrl);
	}
	if(optDIV==2)
	{
		if((getCookie("user_username")!='') || (getCookie("user_password")!=''))
		{
			switch(intId)
			{
				case '1':	
				case '3':
					strUrl = path+"friends/user_home.php";
					break;
				case '2':
					popup();
					return;
					break;
				case '4':
			}
			window.location.replace(strUrl);
			return;
		}
		else
		{
			switch(intId)
			{
				case '1':			
					return_url = path+"../index.php";
					break;
				case '2':
					return_url = path+"../index.php?optDIV=3";
					break;
				case '3':
					return_url = path+"../friends/user_home.php";
					break;
			}
			strUrl = path+"ajax/login.php?return_url="+return_url;
			r.display = "block"; 
			xmlhttpPost(strUrl);
		}
	}
	if(optDIV==3)
	{
		r.display = "block"; 
		xmlhttpPost(path+'ajax/chatterms.php');
	}
} 

function xmlhttpPost(strURL) 
{
	var xmlHttpReq = false;
	var self = this;
// Mozilla/Safari
    if (window.XMLHttpRequest) 
        self.xmlHttpReq = new XMLHttpRequest();
// IE
    else if (window.ActiveXObject) 
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");

	self.xmlHttpReq.open('POST', strURL, true);
	self.xmlHttpReq.onreadystatechange = function() 
	{
	    if (self.xmlHttpReq.readyState == 4) 
            updatepage(self.xmlHttpReq.responseText);
    }
    self.xmlHttpReq.send(getquerystring());
}

function getquerystring() 
{
   	var qstr="";
    return qstr;
}

function updatepage(str)
{
	document.getElementById('menu_detail').style.backgroundImage="";
	if(optDIV1==2)
	{
		document.getElementById('menu_detail').style.background="url(images/login.png) no-repeat left center white";
		document.getElementById('menu_detail').style.paddingLeft="60px";
	}
	document.getElementById('menu_detail').innerHTML = str;
}


function close_div(divID)
{
	document.getElementById(divID).style.display="none";
}

function contact()
{
	window.open('common/webmaster.php','','resizable=1,HEIGHT=400,WIDTH=650');
}
