function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=2,location=0,statusbar=1,menubar=0,resizable=0,width=750,height=525,left = 100,top = 134');");
}
function popUpSmall(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=2,location=0,statusbar=1,menubar=0,resizable=0,width=200,height=150,left = 100,top = 134');");
}
// load htmlarea
	_editor_url = "";                     // URL to htmlarea files
	var win_ie_ver = parseFloat(navigator.appVersion.split("MSIE")[1]);
	if (navigator.userAgent.indexOf('Mac')        >= 0) { win_ie_ver = 0; }
	if (navigator.userAgent.indexOf('Windows CE') >= 0) { win_ie_ver = 0; }
	if (navigator.userAgent.indexOf('Opera')      >= 0) { win_ie_ver = 0; }
	if (win_ie_ver >= 5.5) {
		 document.write('<scr' + 'ipt src="' +_editor_url+ 'editor.js"');
		 document.write(' language="Javascript1.2"></scr' + 'ipt>');
	} else { document.write('<scr'+'ipt>function editor_generate() { return false; }</scr'+'ipt>'); }


browserName = navigator.appName;
browserVer = parseInt(navigator.appVersion);

ns3up = (browserName == "Netscape" && browserVer >= 3);
ie4up = (browserName.indexOf("Microsoft") >= 0 && browserVer >= 4);

function doPic(imgName) {
if (ns3up || ie4up) {
imgOn = ("" + imgName);
document.main_ad_image.src = imgOn;
}
}

function doMedia(mediaName) {
if (ns3up || ie4up) {
mediaOn = ("" + mediaName);
document.main_ad_media.src = mediaOn;
}
}

function open_mychatbox(fromname,toname,item) {
	location.href="#Chat"
	var chatwindow=window.open("http://www.ebuy-online.com/sellers_chat.php?from_name="+fromname+"&to_name="+toname+"&item="+item, "", "width=500,height=500;scrollbars=on;status=on;");
	document.getElementById('chatlink').style.display='none';
	setTimeout('showchatlink()',300000);
}

function showchatlink(){
	document.getElementById('chatlink').style.display='block';
}	

function open_otherschatbox(to_name,item){
	var from_name = '';
		//alert(document.getElementById("myname").value);
	from_name = document.getElementById('myname').value;
	if(from_name==''){
	 document.getElementById('errormessage').innerHTML="Please Enter Your Name";
	}
	else{
		open_mychatbox(from_name,to_name,item);
		document.getElementById('nonuser').style.display='none';
	} 
}

function doBlink() {
	var blinking = document.getElementsByName("online");
	for (var i=0; i<blinking.length; i++){
		blinking[i].style.visibility = (blinking[i].style.visibility == "") ? "hidden" : "" ;
	}
}

function startBlink() {
		setInterval("doBlink()",500)
}

function displaychating(uname){
		var self = this;
	  if (window.XMLHttpRequest) {
	      self.xmlHttp = new XMLHttpRequest();
	  }
	  else if (window.ActiveXObject) {
	      self.xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
	  }
			var strurl = "displaychat.php?uname="+uname;
			self.xmlHttp.onreadystatechange = stateChanged;
			self.xmlHttp.open("GET",strurl,true);
			self.xmlHttp.send(null);
}

function stateChanged(){
		if(xmlHttp.readyState==4||xmlHttp.readyState=="complete"){
			chatuser = self.xmlHttp.responseText.split(",");
			if(chatuser[0] == 'yes'){
				window.open("http://www.ebuy-online.com/sellers_chat.php?from_name="+chatuser[2]+"&to_name="+chatuser[1]+"&chat_item="+chatuser[3]+"&session="+chatuser[4],"","width=500,height=500;scrollbars='on';status='on';");
			}
		}	
}

function states()
{
	var self = this;
  	if (window.XMLHttpRequest) {
     	 self.xmlHttp = new XMLHttpRequest();
  	}	
  	else if (window.ActiveXObject) {
  		try{
      	self.xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
      }catch(e){
      	self.xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
      }
  	}		
  	var url="states.php";
	url=url+"?q="+document.getElementById('country').value;
	url=url+"&sid="+Math.random();
	self.xmlHttp.onreadystatechange = stateDisplay;
	self.xmlHttp.open("GET",url,true);
	self.xmlHttp.send(null);
}
function stateDisplay() 
{ 
	if (self.xmlHttp.readyState==4 || self.xmlHttp.readyState=="complete")
	{ 
	 	var browserName = navigator.appName; 
	 	var cbox = self.xmlHttp.responseText.split(';');
	 	if(browserName == "Microsoft Internet Explorer"){
		 	document.getElementById('state').length=0;
		 	var defaultOption = document.createElement('<option value="">');
		 	document.getElementById('state').options.add(defaultOption);
		 	defaultOption.innerText = "-- Select State --";
		 	for(i=0;i<cbox.length-1;i++){
		 		indoption = cbox[i].split(':');
		 		var newOption = document.createElement('<option value="'+indoption[0]+'">'); 
		 		document.getElementById('state').options.add(newOption);
		 		newOption.innerText = indoption[1];
		 	}
		}else{
			var optionstr = "<option value=''>-- Select State --</option>";
			for(i=0;i<cbox.length-1;i++){
		 		var indoption = cbox[i].split(':');
		 		optionstr += "<option value='"+indoption[0]+"'>"+indoption[1]+"</option>";
		 	}
		 	document.getElementById('state').innerHTML = optionstr;
		}
	} 
}
function thisMovie(movieName) {
	if (navigator.appName.indexOf("Microsoft") != -1) {
		return window[movieName];
 	} else {
		return document[movieName];
 	}
}
function showIntroDiv() {
	document.getElementById('bg').style.visibility = "visible";
	document.getElementById('introDIV').style.display = "block";
	document.getElementById('introDIV').style.left = ((document.body.offsetWidth)-640) / 2+"px";
}
function closeIntroDiv() {
	if(typeof thisMovie('FLASH') != 'undefined') {
		$f(0).stop();
	}
	document.getElementById('bg').style.visibility = "hidden";
	document.getElementById('introDIV').style.display = "none";
}
function changeLocation() {
	document.getElementById('bg').style.visibility = "visible";
	document.getElementById('mapDIV').style.display = "block";
	document.getElementById('mapDIV').style.left = ((document.body.offsetWidth)-640) / 2+"px";
	document.getElementById("main_text").style.overflow = 'hidden';
	document.getElementById("main_text").innerHTML = '<div id="ajaxLoader" style="position:absolute;align:center; display:none;left:20%;right:30%"><img src="images/ajax-loader.gif" style="z-index:1000;"></div>';
}
function closeChangeLocation() {
	document.getElementById("main_text").innerHTML = '';
	document.getElementById('bg').style.visibility = "hidden";
	document.getElementById('mapDIV').style.display = "none";
}
function clear_searchtext() {
	if(document.getElementById('referring_id').value == "Search City.....") {
		document.getElementById('referring_id').value = "";
	}
	else if(document.getElementById('referring_id').value == "") {
		document.getElementById('referring_id').value = "Search City.....";
	}
}
function showMap(map_type) {
	if(map_type == 'usa_canada')
	{
		document.getElementById("div_europe_map").style.display = 'none';
		document.getElementById("div_usa_canada_map").style.display = 'block';
		document.getElementById("map_container").innerHTML = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="500" height="430" id="usa_canada_locator_2">'+
				'<param name="allowScriptAccess" value="sameDomain" /><param name="movie" value="images/usa_canada_locator_2.swf" /><PARAM NAME=FlashVars VALUE="xmlfile1=usa_canada_locator.xml"><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" />'+
				'<embed src="images/usa_canada_locator_2.swf?xmlfile1=usa_canada_locator.xml" quality="high" bgcolor="#ffffff" width="500" height="430" name="usa_canada_locator_2" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />'+
			'</object>';
	} else if(map_type == 'europe') {
		document.getElementById("div_usa_canada_map").style.display = 'none';
		document.getElementById("div_europe_map").style.display = 'block';
		document.getElementById("map_container").innerHTML = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="500" height="470" id="europe_locator2_9" align="middle">'+
				'<param name="allowScriptAccess" value="sameDomain" /><param name="movie" value="images/europe_locator2_9.swf" /><PARAM NAME=FlashVars VALUE="xmlfile1=europe_locator.xml"><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" />'+
				'<embed src="images/europe_locator2_9.swf?xmlfile1=europe_locator.xml" quality="high" bgcolor="#ffffff" width="500" height="470" name="europe_locator2_9" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />'+
			'</object>';
		document.getElementById("main_text").innerHTML = '';
		document.getElementById("main_text").style.overflow = 'hidden';
		document.getElementById("main_text").innerHTML = '<div id="ajaxLoader" style="position:absolute;align:center; display:none;left:20%;right:30%"><img src="images/ajax-loader.gif" style="z-index:1000;"></div>';
	}
}
function populateRefSuggestion(str)
{
	var customarray = new Array();
	var customarray = str.split(',');
	var obj = new actb(document.getElementById('referring_id'),customarray);
}
function selectFromDropdown(str) {
	str_arr = str.split('.');
	location.href = 'index.php?city_code='+str_arr[1];
}		
function redirect_to(country_code)
{
	location.href = 'index.php?country_code='+country_code;
}
function set_text(state_code)
{
	document.getElementById("main_text").style.overflow = 'auto';
	document.getElementById('ajaxLoader').style.display = 'block';
	var xmlHttpReq = false;
  var self = new XMLHttpRequest();
	// Mozilla/Safari
	if (window.XMLHttpRequest) {
		self.xmlHttpReq = new XMLHttpRequest();
	}
	// IE
	else if (window.ActiveXObject) {
	  self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	var strURL = "show_cities.php?state_code="+state_code;
	self.xmlHttpReq.open('POST', strURL, true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function() {
		if (self.xmlHttpReq.readyState == 4) {
			handle_set_text(self.xmlHttpReq.responseText);
		}
	}
  self.xmlHttpReq.send(strURL);
}
function handle_set_text(str)
{
	var str_array = str.split("|");
	document.getElementById("main_text").innerHTML = str_array['0'];
	populateRefSuggestion(str_array['1']);
}
var msg = 'Welcome New users Register today, It is FREE. Put your Credit Cards Away. It is FREE to Sell, Bid and Interact with other Users!'
var colorTimer = null;

function toHex(n){
	var hexChars = '0123456789ABCDEF';
	if (n == 0) return n;
	var j, k;
	var temp = '';
	while (n != 0){
		j = n % 16;
		n = (n - j)/16;
		temp = hexChars.charAt(j) + temp;
	}
	return temp;
}
function colorize(){
	if (!document.getElementById) return;
	for (i=0; i<msg.length; i++){
		k = Math.round(Math.random() * 16777215);
		k = toHex(k);
		while (k.length < 6){
			k = k + '0';
		}
		document.getElementById('colorizer' + i).style.color = '#' + k;
	}
	colorTimer = window.setTimeout('colorize()', 200);
}
