var slidespeed=1;
var slidespeedindex=2;
//Specify pixels gap between each slideshow rotation (use integer):
var slideshowgap_3=5;
var actualwidth = new Array();
var cross_slide = new Array();
var cross_slide2 = new Array();
var copyspeed = new Array();
var lefttime = new Array();
function t_getelement(id){
	return W3C?document.getElementById(id):
		IE4?document.all[id]:
		NS4?document[id]:false;
}

function iknoget(){}

function main_selected(main_category) {
	var form = document.forms[0];

	var l = subcategories[main_category].length;

	form.sub_category.options.length = l;
	form.sub_category.selectedIndex = 0;
	if(l == 0) {
		form.sub_category.options[0] = new Option('Unfortunately no sub categories', 0);
	} else {
		for (i = 0; i < l; i++) {
			form.sub_category.options[0] = new Option('Please choose category', 0);
			var information = subcategories[main_category][i].split(":");
			var category_id = information[0];
			var category = information[1];
			form.sub_category.options[i + 1] = new Option(category, category_id);
		}
	}
	form.sub_category.selectedIndex = 0;
}

function sub_selected(sub_category) {
	var form = document.forms[0];
	for(i = 0 ; i < form.sub_category.options.length ; i++) {
		if(form.sub_category.options[i].value == sub_category) {
			form.sub_category.selectedIndex = i;
		}
	}
}

function winopen(windowURL,windowname,w,h){
	popup = window.open(windowURL,windowname,"width="+w+",height="+h+",toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes");
	popup.focus();
}

function PopupImage(titre,img)
{
	w=open("",'image','width=500,height=315,toolbar=no,scrollbars=no,resizable=yes');	
	w.document.write("<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'><html><head><title>"+titre+"</title><meta http-equiv='Content-Type' content='text/html; charset=windows-874'></head>");
	w.document.write('<script type="text/javascript" language="JavaScript">function checksize()  { if (document.images[0].complete) {  window.resizeTo(document.images[0].width+30,document.images[0].height+60); window.focus();} else { setTimeout("check()",250) } }</'+'script>');
	w.document.write('<body onload="checksize()" leftMargin="0" topMargin="0" marginwidth="0" marginheight="0"><center><img src="'+img+'" alt="" border="0" /></center>');
	w.document.write("");
	w.document.write("</body></html>");
	w.document.close();
}

function validEmail(email) {
var invalidChars;
invalidChars = " /:,;"
if (email == "") {
    return false
}

for (i=0; i<invalidChars.length; i++) {
    badChar = invalidChars.charAt(i)
    if (email.indexOf (badChar,0) != -1) {
        return false
    }
}  // for (i=o.. 

atPos = email.indexOf ("@",1)

if (atPos == -1) {
    return false
}

if ( email.indexOf ("@", atPos+1) != -1) {
    return false
}
periodPos = email.indexOf (".", atPos)

if ( periodPos == -1) {
    return false
}

if ( periodPos+3 > email.length)    {
    return false
}
return true
}  // validEmail 


function validForm(form) {
	var message;
	message = '';
	if(!validEmail(form.email.value) || form.email.value != form.email2.value) {
		message += "Please check email address and make sure the confirmed email address is correct\n";
	}
	
	if(form.fname.value == '' || form.lname.value == '') {
		message += "Please specify your full name\n";
	}
	
	if(message != '') {
		alert(message);
		return false;
	} else {
		return true;
	}	
}


function CurrencyPopup(price,QueryString) {
    CurrencyWindow = window.open ('', 'CurrencyWindow', 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1,height=170,width=600')
    CurrencyWindow.focus()
    CurrencyWindow.location.href = 'http://www.xe.net/ecc/input.cgi?Template=sw&AmountSet='+price+'&'+QueryString
}

function objdrag(obj){
	alert(obj);
		var objleft= window.event.x-obj.style.left;
	obj.style.left=window.event.x;
	//document.getElementById("div1_2").style.left=document.getElementById("div1_2").style.left-objleft;
}

function fillup(){
for(i=0;i<id.length;i++){	
copyspeed[id[i]]=slidespeed;
cross_slide[id[i]]=document.getElementById("div"+[id[i]]);
cross_slide2[id[i]]=document.getElementById("div"+[id[i]]+"_2");
cross_slide2[id[i]].innerHTML=cross_slide[id[i]].innerHTML;
actualwidth[id[i]]=cross_slide[id[i]].offsetWidth;
cross_slide2[id[i]].style.left=actualwidth[id[i]]+"px";
lefttime[id[i]]=setInterval("slideleft("+[id[i]]+")",30);
}
}
//window.onload=fillup_3;
function fillupindex(){
for(i=0;i<id.length;i++){	
copyspeed[id[i]]=slidespeedindex;
cross_slide[id[i]]=document.getElementById("div"+[id[i]]);
cross_slide2[id[i]]=document.getElementById("div"+[id[i]]+"_2");
cross_slide2[id[i]].innerHTML=cross_slide[id[i]].innerHTML;
actualwidth[id[i]]=cross_slide[id[i]].offsetWidth;
cross_slide2[id[i]].style.left=actualwidth[id[i]]+"px";
lefttime[id[i]]=setInterval("slideleft("+[id[i]]+")",30);
}
}

function slideleft(id){
if (parseInt(cross_slide[id].style.left)>(actualwidth[id]*(-1)+8))
cross_slide[id].style.left=parseInt(cross_slide[id].style.left)-copyspeed[id]+"px";
else
cross_slide[id].style.left=parseInt(cross_slide2[id].style.left)+actualwidth[id]+"px";

if (parseInt(cross_slide2[id].style.left)>(actualwidth[id]*(-1)+8))
cross_slide2[id].style.left=parseInt(cross_slide2[id].style.left)-copyspeed[id]+"px";
else
cross_slide2[id].style.left=parseInt(cross_slide[id].style.left)+actualwidth[id]+"px";

}
