Xoffset=15;
Yoffset=15;

var old,skn,iex=(document.all),yyy=-1000;

var ns4=document.layers
var ns6=document.getElementById&&!document.all
var ie4=document.all

if (ns4)
skn=document.dek
else if (ns6)
skn=document.getElementById("dek").style
else if (ie4)
skn=document.all.dek.style
if(ns4)document.captureEvents(Event.MOUSEMOVE);
else{
skn.visibility="visible"
skn.display="none"
}
document.onmousemove=get_mouse;

function popup(msg){
var content="<TABLE BORDER=0 CELLPADDING=1 CELLSPACING=1 "+
"BGCOLOR=#777777><TD ALIGN=center bgcolor=#c8e8fe><FONT COLOR=black SIZE=1 face=\"Verdana, Arial, Helvetica, sans-serif\">"+msg+"</FONT></TD></TABLE>";
yyy=Yoffset;
 if(ns4){skn.document.write(content);skn.document.close();skn.visibility="visible"}
 if(ns6){document.getElementById("dek").innerHTML=content;skn.display=""}
 if(ie4){document.all("dek").innerHTML=content;skn.display=""}
}

function get_mouse(e){
var x=(ns4||ns6)?e.pageX:event.x+document.body.scrollLeft;
skn.left=x+Xoffset;
var y=(ns4||ns6)?e.pageY:event.y+document.body.scrollTop;
skn.top=y+yyy;
}

function kill(){
yyy=-1000;
if(ns4){skn.visibility="hidden";}
else if (ns6||ie4)
skn.display="none"
}

function myConfirm(msg)
{
    if ( ! window.showModalDialog || window.external.IYBrowserExtend) {
    if(!confirm(msg)) return false;
    } else {
    var oArguments = {
	Message : msg
    };
    var oAction = window.showModalDialog("confirmation.html",oArguments,"dialogHeight:150px;dialogWidth:300px;status:no;help:no;resizable:yes;scroll:no;");
			
    if(oAction)
    {
    if(!oAction.confirmed) return false;
    }
} 
    return true;
}

function getxmlhttp() {

var xmlhttp=false;
try {
	// if Javascript version>5
	xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
	//if not use the older ActiveX object
	try {
	//if using IE
	xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	} catch (E) {
	xmlhttp=false;
	}
}
// if not using IE, create a javascript instance of the object
if(!xmlhttp && typeof XMLHttpRequest != 'undefined') {
	xmlhttp=new XMLHttpRequest();
}

return xmlhttp;

}

function onNewest() {

document.getElementById('newest').style.display='block';
document.getElementById('popular').style.display='none';
document.getElementById('rated').style.display='none';
//document.getElementById('sponsored').style.display='none';
document.getElementById('tab-newest').className = "tab-on";
document.getElementById('tab-popular').className = "tab";
document.getElementById('tab-rated').className = "tab";
//document.getElementById('tab-sponsored').className = "tab";

}

function onPopular() {

document.getElementById('newest').style.display='none';
document.getElementById('popular').style.display='block';
document.getElementById('rated').style.display='none';
//document.getElementById('sponsored').style.display='none';
document.getElementById('tab-newest').className = "tab";
document.getElementById('tab-popular').className = "tab-on";
document.getElementById('tab-rated').className = "tab";
//document.getElementById('tab-sponsored').className = "tab";

}

function onRated() {

document.getElementById('newest').style.display='none';
document.getElementById('popular').style.display='none';
document.getElementById('rated').style.display='block';
//document.getElementById('sponsored').style.display='none';
document.getElementById('tab-newest').className = "tab";
document.getElementById('tab-popular').className = "tab";
document.getElementById('tab-rated').className = "tab-on";
//document.getElementById('tab-sponsored').className = "tab";

}


function onSponsored() {

document.getElementById('newest').style.display='none';
document.getElementById('popular').style.display='none';
document.getElementById('rated').style.display='none';
//document.getElementById('sponsored').style.display='block';
document.getElementById('tab-newest').className = "tab";
document.getElementById('tab-popular').className = "tab";
document.getElementById('tab-rated').className = "tab";
//document.getElementById('tab-sponsored').className = "tab-on";

}


function newList(catlist, numClear,field1,field2) {
	var frm = document.add_listing;
	if(numClear == 4) { clearCombo(frm.Select1); clearCombo(frm.Select2); clearCombo(frm.Select3); clearCombo(frm.Select4);
	}
	else if(numClear == 3) { clearCombo(frm.Select2); clearCombo(frm.Select3); clearCombo(frm.Select4); }
	else if(numClear == 2) { clearCombo(frm.Select3); clearCombo(frm.Select4); }
	else if(numClear == 1) { clearCombo(frm.Select4); }

	var loop_end = catlist.length;
	var j=0; 
	var tmpnamearr = new Array();
	var tmparr = new Array();
	var ls=0;
	for(h=0;h<loop_end;h++)
	if(catlist[h] && catlist[h][1] == field1.options[field1.selectedIndex].value)
	{
		ls=h;
		break;
	}
	h=ls; 

	while(catlist[h] && field1.options[field1.selectedIndex].value == catlist[h][1])
	{
		tmpnamearr[j] = catlist[h][2];
		tmparr[catlist[h][2]] = catlist[h][0];
		j++;
		h++;
	} //end for

	tmpnamearr = tmpnamearr.sort();

	for(h=0;h<j;h++) 
	{
		newOpt2 = tmpnamearr[h];
		newOpt = tmparr[newOpt2];
		field2.length=h+1;
		field2.options[h] = new Option(newOpt2,newOpt)
	}
	if(j == 0) 
	{
		frm.categ.value = field1.options[field1.selectedIndex].value
		frm.categ_interm.value = field1.options[field1.selectedIndex].value
		hide_all();
		for(y=2;y<(6-numClear);y++) 
		{
			document.getElementById('box'+y).style.display='block'
		}
	}
	else 
	{
		if(numClear <=3) frm.categ.value = field1.options[field1.selectedIndex].value
		else frm.categ.value=0;
		frm.categ_interm.value = field1.options[field1.selectedIndex].value
		hide_all();
		for(y=2;y<(7-numClear);y++) 
			document.getElementById('box'+y).style.display='block'
	}

}//newlist
 

function finale(inBox) 
{
	frm = document.add_listing;
	frm.categ.value = inBox.options[inBox.selectedIndex].value
	frm.categ_interm.value = inBox.options[inBox.selectedIndex].value
}

function clearCombo(elem){
	var i;
	for (i = elem.options.length; i >= 0; i--) 
		elem.options[i] = null;
	elem.selectedIndex = -1;
}

function hide_all(){
	var i;
	for(i=2;i<6;i++) 
		document.getElementById('box'+i).style.display='none';
}

function edit(catlist, parents)
{ 
	nr_combo=parents.length;
	var loop_end=catlist.length;
	var ok =new Array(); 
	var ls =new Array();
	var i;
	var j=new Array();
	var cat = new Array();

	for(i=1;i<=nr_combo;i++)
	{
		ok[i]=0;
		ls[i]=-1;
		cat[i-1]=-1;
	}

	for(h=0;h<loop_end;h++)
	{ 
		for( i=1;i<=nr_combo;i++)
		if(catlist[h] && catlist[h][1] == parents[i-1][1] && ok[i]==0)
		{
			ls[i]=h; ok[i]=1;
		}
		var pas=1;
		for( i=1;i<=nr_combo;i++)
			if(ok[i]==0) pas=0;
		if(pas==1) break;
	}

	for(i=1;i<=nr_combo;i++)
	{
		h=ls[i];
		j[i]=0;
		while(catlist[h] && parents[i-1][1]== catlist[h][1])
		{
			j[i]++; 
			if(parents[i-1][0]==catlist[h][0])
			{
				cat[nr_combo-i]=j[i];
				break;
			}
			h++; 
		}
	}

	var box;
	for(i=0;i<nr_combo;i++)
	{
		if(i==0 )
		{     
			if(cat[0]>0)
	     		{
				document.add_listing.SelectM.selectedIndex=cat[0]-1;
				if(nr_combo>1)
				{
					document.getElementById('box2').style.display='block';
					newList(catlist, 4, document.add_listing.SelectM,document.add_listing.Select1); 
				}
			}
		}
		else
		if(i==nr_combo)
		{
			box=i+1;
			field1=document.getElementById("Select"+i);
			field2=document.getElementById("Select"+box);
			document.getElementById('box'+box).style.display='block'
			document.getElementById("Select"+i).selectedIndex=cat[i]-1;
		}
		else
		if(cat[i]>0)
		{
			box=i+1;
			field1=document.getElementById("Select"+i);
			field2=document.getElementById("Select"+box);
			document.getElementById('box'+box).style.display='block'
			document.getElementById("Select"+i).selectedIndex=cat[i]-1;
			newList(catlist, 4-i,field1,field2);
		}
	}
} 

function n_window(theurl,w,h)
{
 // set the width and height
 var the_width=w;
 var the_height=h;
 // set window position
 var from_top=350;
 var from_left=500;
 // set other attributes
 var has_toolbar='no';
 var has_location='no';
 var has_directories='no';
 var has_status='no';
 var has_menubar='no';
 var has_scrollbars='no';
 var is_resizable='yes';
 // attributes put together
 var the_atts='width='+the_width+'show,height='+the_height+',top='+from_top+',screenY='+from_top+',left='+from_left+',screenX='+from_left;
 the_atts+=',toolbar='+has_toolbar+',location='+has_location+',directories='+has_directories+',status='+has_status;
 the_atts+=',menubar='+has_menubar+',scrollbars='+has_scrollbars+',resizable='+is_resizable;
 // open window
 window.open(theurl,'',the_atts);
}
