function is_numeric( mixed_var ) {

 

    return !isNaN( mixed_var );

}



function display(id)

{

	document.getElementById(id).style.display="inline";

}



function no_display(id)

{

	document.getElementById(id).style.display="none";

}



function login_admin()

{

	

	var username=document.getElementById('username').value;

	var password=document.getElementById('password').value;

	

		 if(username.length==0)

	{

		alert('Please enter your username!');

		return false;

	}



   	else if(password.length==0)

   	{

   		alert('Please enter your password!');

   		return false;

   	}



	

   	

   	

   	 var ax = new XHConn();

  	 var on_finish = function(bx) {

  

   	

  

  

  	 	

  	 reply=bx.responseText;

	

	 

	 if(reply==2)

     {

     alert('Your username or password is wrong!');

     return false;

     }

     

   

   	

   	 if(username.length!=0 && password.length!=0 && reply!='2'){

   	 	   document.getElementById('form').submit();

   	 	

   	 }

   	

	 }



     ax.connect('http://www.darkhorse.com.au/admin/ajax/login.php','GET','username='+username+'&password='+password,on_finish);

     return false;

	

}



function show(id)

{

	if(document.getElementById(id).style.display!="inline")

	document.getElementById(id).style.display="inline";

	else

	document.getElementById(id).style.display="none";

}

function hide(id)

{

	

	document.getElementById(id).style.display="none";

}



function validate_form1(category)

{

	var product = document.getElementById('product').value;

	   	

	if(product.length==0)

	{

			alert('Please enter the product name!');

			return false;

	}

	

	while(product.match("&"))

	{

	product =product.replace("&", "(ampersant)");

	}



	

   	 var ax = new XHConn();

  	 var on_finish = function(bx) {

	  

		 	

	  	 reply=bx.responseText;

		 if(reply=="2")	

		 

		 {

		 	alert('This product already exist!');

		 	return false;

		 }

			   

	   	

	   	 if(product.length!=0  && reply=='1'){

	   	 

	   	 	   document.getElementById('form_add_product').submit();

	   	 	

	   	 }

	   	 

	   	 

   	

	 }



     ax.connect('http://www.darkhorse.com.au/admin/ajax/add_product.php','GET','product='+product+'&category='+category,on_finish);

     return false;

}









function validate_form2()

{

	var product2 = document.getElementById('product2').value;

	var type = document.getElementById('type').value;	

	 

	

	if(product2=="-" )

		{

			alert('Please select the product type name!');

			return false;

		}

	

	if(type.length==0 )

		{

			alert('Please enter the product type name!');

			return false;

		}

	

   	 var ax = new XHConn();

  	 var on_finish = function(bx) {

  	 		 	 	

	  	 reply=bx.responseText;

		 if(reply=="2")	

		 

		 {

		 	alert('This type of this product already exist!');

		 	return false;

		 }

			   

	   	

	   	 if(type.length!=0  && reply=='1'){

	   	 	   document.getElementById('form_add_type').submit();

	   	 	

	   	 }

   	

	 }



     ax.connect('http://www.darkhorse.com.au/admin/ajax/add_type.php','GET','product='+product2+'&type='+type,on_finish);

     return false;

}







function validate_form3(category)

{

	var product = document.getElementById('eproduct3').value;

	var productid = document.getElementById('product3').value;



	if(productid=="-" )

		{

			alert('Please select the product name!');

			return false;

		}

	

  	 	

	if(product.length==0)

	{

			alert('Please enter the product name!');

			return false;

	}

	while(product.match("&"))

	{

	product =product.replace("&", "(ampersant)");

	}



   	 var ax = new XHConn();

  	 var on_finish = function(bx) {

  	 	

	  	 reply=bx.responseText;

		 if(reply=="2")	

		 

		 {

		 	alert('This product already exist!');

		 	return false;

		 }

			   

	   	

	   	 if(product.length!=0  && reply=='1'){

	   	 

	   	 	   document.getElementById('form_edit_product').submit();

	   	 	

	   	 }

   	

	 }



     ax.connect('http://www.darkhorse.com.au/admin/ajax/edit_product.php','GET','product='+product+'&category='+category+'&productid='+productid,on_finish);

     return false;

}



function populate_input(select_id,input_id)

{

	var select_id_text=document.getElementById(select_id).options[document.getElementById(select_id).selectedIndex].text;

	

	 document.getElementById(input_id).value=select_id_text;

	

		

}



function populate_select(select_id,divid,category)

{

	var select_id_value=document.getElementById(select_id).value;

	var dividinner=document.getElementById(divid);

	 var ax = new XHConn();

  	 var on_finish = function(bx) {

	  	

	

	   	 	 	

	  	 reply=bx.responseText;

		 dividinner.innerHTML=reply;

		 if(reply!='<select name="type4" id="type4"  disabled"><option value="-">No Types</option></select>')

		 {

		 	document.getElementById('etype4').disabled=false;

		 	populate_input('type4','etype4');

		 	

		 }

		 else

		 {

		 document.getElementById('etype4').value="";

		 document.getElementById('etype4').disabled=true;

		 }

   	

	 }



     ax.connect('http://www.darkhorse.com.au/admin/ajax/populate_select.php','GET','productid='+select_id_value+'&category='+category,on_finish);

}



function populate_select2(select_id,divid,category)

{

	var select_id_value=document.getElementById(select_id).value;

	var dividinner=document.getElementById(divid);

	 var ax = new XHConn();

  	 var on_finish = function(bx) {

	  	

	

	   	 	 	

	  	 reply=bx.responseText;

		 dividinner.innerHTML=reply;

		

   	

	 }



     ax.connect('http://www.darkhorse.com.au/admin/ajax/populate_select2.php','GET','productid='+select_id_value+'&category='+category,on_finish);

}







function populate_select3(select_id,divid)

{

	var select_id_value=document.getElementById(select_id).value;

	var dividinner=document.getElementById(divid);

	 var ax = new XHConn();

  	 var on_finish = function(bx) {

	  	

	

	   	 	 	

		 reply=bx.responseText;

		 dividinner.innerHTML=reply;

		 if(reply!='<select name="qty11" id="qty11"  disabled"><option value="-">No Quantity</option></select>')

		 {

		 	 document.getElementById('eqty11').disabled=false;

		 	populate_input('qty11','eqty11');

		 	

		 }

		 else

		 {

		 	 document.getElementById('eqty11').value="";

			document.getElementById('eqty11').disabled=true;

		 }

		

   	

	 }



     ax.connect('http://www.darkhorse.com.au/admin/ajax/populate_select3.php','GET','productid='+select_id_value,on_finish);

}





function populate_select4(select_id,divid)

{

	var select_id_value=document.getElementById(select_id).value;

	var dividinner=document.getElementById(divid);

	 var ax = new XHConn();

  	 var on_finish = function(bx) {

	  	

	

	   	 	 	

		 reply=bx.responseText;

		 dividinner.innerHTML=reply;

		

   	

	 }



     ax.connect('http://www.darkhorse.com.au/admin/ajax/populate_select4.php','GET','productid='+select_id_value,on_finish);

}







function validate_form4(category)

{

	var type = document.getElementById('etype4').value;



	var productid = document.getElementById('product4').value;  

	if(!(productid=="-" && type.length==0 )	)

		var typeid = document.getElementById('type4').value;

		

	if(productid=="-" )

		{

			alert('Please select the product name!');

			return false;

		}

	

	 if(type.length==0 )

		{

			alert('Please enter the type name!');

			return false;

		}	

		

   	 var ax = new XHConn();

  	 var on_finish = function(bx) {

  	 	

  

	   	 	 	

	  	 reply=bx.responseText;

		 if(reply=="2")	

		 

		 {

		 	alert('This type already exist!');

		 	return false;

		 }

			   

	   

	   	 if(type.length!=0  && reply=='1'){

	   	 			

	   	 	   document.getElementById('form_edit_type').submit();

	   	 	

	   	 }

   	

	 }

	

     ax.connect('http://www.darkhorse.com.au/admin/ajax/edit_type.php','GET','type='+type+'&category='+category+'&typeid='+typeid+'&productid='+productid,on_finish);

     return false;

}







function validate_form5()

{

	

	var productid = document.getElementById('product5').value;

	if(productid=="-" )

		{

			alert('Please select the product name!');

			return false;

		}

	

  	 	

	  		

	   	 	 	  	

   	 var ax = new XHConn();

  	 var on_finish = function(bx) {

  	 	

  	 

	  	 reply=bx.responseText;

		 

	   	

	   	 if(reply=='1'){

	   	 

	   	 	   document.getElementById('form_delete_product').submit();

	   	 	

	   	 }

   	

	 }



     ax.connect('http://www.darkhorse.com.au/admin/ajax/delete_product.php','GET','productid='+productid,on_finish);

     return false;

}











function validate_form6()

{

	



	var productid = document.getElementById('product6').value;  

	

	if(productid=="-" )

		{

			alert('Please select the product name!');

			return false;

		}

		

	if(!(productid=="-")	)

		var typeid = document.getElementById('type6').value;

		

   	 var ax = new XHConn();

  	 var on_finish = function(bx) {

	 	

	  	 reply=bx.responseText;

		

	   

	   	 if(reply=='1'){

	   	 			

	   	 	   document.getElementById('form_delete_type').submit();

	   	 	

	   	 }

   	

	 }

	

     ax.connect('http://www.darkhorse.com.au/admin/ajax/delete_type.php','GET','typeid='+typeid,on_finish);

     return false;

}







function validate_form7(type)

{

	



	var qty = document.getElementById('qty').value;  

	var productid = document.getElementById('product7').value;

	

	if(productid=="-" )

		{

			alert('Please select the product name!');

			return false;

		}

	  

		

	

		if(qty.length==0 )

		{

			alert('Please enter the quantity!');

			return false;

		}

		else if(!is_numeric(qty))

		{

			alert('The quantity must be a number!');

			return false;

		}

		

	



		

	

		

   	 var ax = new XHConn();

  	 var on_finish = function(bx) {

  	 	

  	

	   	 	 	

	  	 reply=bx.responseText;

		 if(reply=="2")	

		 

		 {

		 	alert('This quantity already exist!');

		 	return false;

		 }

	   

	   	 if(qty.length!=0  && reply=='1'){

	   	 			

	   	 	   document.getElementById('form_add_price').submit();

	   	 	

	   	 }

   	

	 }

	

     ax.connect('http://www.darkhorse.com.au/admin/ajax/add_price.php','GET','productid='+productid+'&qty='+qty,on_finish);

     return false;

}





function validate_form8(priceline1,type)

{



	

	var rp=document.getElementById('rpp'+priceline1).value;

	var tp=document.getElementById('tpp'+priceline1).value;

	



	if( rp.length==0 && tp.length==0 )

		{

			alert('Please enter  the retail price or the trade price!');

			return false;

		}

		

		if(rp.length!=0 && !is_numeric(rp))

		{

			alert('The retail price must be a number!');

			return false;

		}

		else if(tp.length!=0 &&!is_numeric(rp))

		{

			alert('The trade price must be a number!');

			return false;

		}

		

		

	

	

		 	 var ax = new XHConn();

  	 var on_finish = function(bx) {

  	 	

  	

	   	 	 	

	  	 reply=bx.responseText;

	  

		

	   

	   	 if(!( rp.length==0 && tp.length==0) && reply=='1'){

	   	 			

	   	 	   document.getElementById('form_edit_price'+priceline1).submit();

	   	 	

	   	 }

   	

	 }

	

     ax.connect('http://www.darkhorse.com.au/admin/ajax/edit_price.php','GET','priceline1='+priceline1+'&rp='

     +rp+'&tp='+tp+'&type='+type,on_finish);

     return false;

}

	



function validate_form9(priceline1)

{



	

	



  if (confirm("Are you sure you want to delete?"))

  {

		

	

	

	 var ax = new XHConn();

  	 var on_finish = function(bx) {

  	 	

  	

	   	 	 	

	  	 reply=bx.responseText;

	  

	

	   	 if(reply=='1'){

	   	 			

	   	 	   document.getElementById('form_edit_price'+priceline1).submit();

	   	 	

	   	 }

   	

	 }

	

     ax.connect('http://www.darkhorse.com.au/admin/ajax/delete_price.php','GET','priceline1='+priceline1,on_finish);

     return false;

  }

  else return false;

}

	







function validate_form10(id)

{



	

	var event_text=document.getElementById('event_text').value;

	



		if(event_text.length==0)

		{

			alert('Please enter event text!');

			return false;

		}

	

		

		

	

	

		 	 var ax = new XHConn();

  	 var on_finish = function(bx) {

  	 	

  	

	   	 	 	

	  	 reply=bx.responseText;

	  

	

	   

	   	 if( reply=='1'){

	   	 			

	   	 	   document.getElementById('form_add_event').submit();

	   	 	

	   	 }

   	

	 }

	

     ax.connect('http://www.darkhorse.com.au/admin/ajax/add_event.php','GET','id='+id+'&event_text='+event_text,on_finish);

     return false;

}



function validate_form10_user(id)

{



	

	var event_text=document.getElementById('event_text').value;

	



		if(event_text.length==0)

		{

			alert('Please enter event text!');

			return false;

		}

	

		

		

	

	

		 	 var ax = new XHConn();

  	 var on_finish = function(bx) {

  	 	

  	

	   	 	 	

	  	 reply=bx.responseText;

	  

	

	   

	   	 if(trim(reply)=='1'){

	   	 

	   	 	   document.getElementById('form_add_event').submit();

	   	 	

	   	 }

   	

	 }

	

     ax.connect('http://www.darkhorse.com.au/ajax/add_event.php','GET','id='+id+'&event_text='+event_text,on_finish);

     return false;

}





// Removes leading whitespaces

function LTrim( value ) {

	

	var re = /\s*((\S+\s*)*)/;

	return value.replace(re, "$1");

	

}



// Removes ending whitespaces

function RTrim( value ) {

	

	var re = /((\s*\S+)*)\s*/;

	return value.replace(re, "$1");

	

}



// Removes leading and ending whitespaces

function trim( value ) {

	

	return LTrim(RTrim(value));

	

}





function validate_form11()

{

	var qty = document.getElementById('eqty11').value;

	var productid = document.getElementById('product11').value;

	var qtyid = document.getElementById('qty11').value;



	if(productid=="-" )

		{

			alert('Please select the product name!');

			return false;

		}

	

  	 	

	if(qty.length==0)

	{

			alert('Please enter the quantity!');

			return false;

	}

	else if(!is_numeric(qty))

		{

			alert('The quantity must be a number!');

			return false;

		}

	

   	 var ax = new XHConn();

  	 var on_finish = function(bx) {

  	 	

	  	 reply=bx.responseText;

		 if(reply=="2")	

		 

		 {

		 	alert('This quantity already exist!');

		 	return false;

		 }

			   

	   	

	   	 if(qty.length!=0  && reply=='1'){

	   	 

	   	 	   document.getElementById('form_edit_qty').submit();

	   	 	

	   	 }

   	

	 }



     ax.connect('http://www.darkhorse.com.au/admin/ajax/edit_qty.php','GET','qty='+qty+'&productid='+productid+'&qtyid='+qtyid,on_finish);

     return false;

}







function validate_form12()

{

	



	var productid = document.getElementById('product12').value;  

	

	if(productid=="-" )

		{

			alert('Please select the product name!');

			return false;

		}

		

	if(!(productid=="-")	)

		var qtyid = document.getElementById('qty12').value;

		

   	 var ax = new XHConn();

  	 var on_finish = function(bx) {

	 	

	  	 reply=bx.responseText;

		

	   

	   	 if(reply=='1'){

	   	 			

	   	 	   document.getElementById('form_delete_qty').submit();

	   	 	

	   	 }

   	

	 }

	

     ax.connect('http://www.darkhorse.com.au/admin/ajax/delete_qty.php','GET','qtyid='+qtyid,on_finish);

     return false;

}





function create_type_sel()

{

	prod=document.getElementById('bc').options[document.getElementById('bc').selectedIndex].value;

	

		 var ax = new XHConn();

  	 var on_finish = function(bx) {

  	 	 reply=bx.responseText;

  	 	 

  	 	document.getElementById('typesl').innerHTML=reply;

  	 }

  	 	

  	 	 ax.connect('http://www.darkhorse.com.au/ajax/create_type_sel.php','GET','prod='+prod,on_finish);

     return false;

  	

}



function create_qty_sel()

{

	prod=document.getElementById('bc').options[document.getElementById('bc').selectedIndex].value;



	 var ax = new XHConn();

  	 var on_finish = function(bx) {

  	 	 reply=bx.responseText;

  	 	document.getElementById('qtysl').innerHTML=reply;

  	 }

  	 	

  	 	 ax.connect('http://www.darkhorse.com.au/ajax/create_qty_sel.php','GET','prod='+prod,on_finish);

     return false;

  	

}



function create_prod_sel()

{

	

	

	 var ax = new XHConn();

  	 var on_finish = function(bx) {

  	 	 reply=bx.responseText;

  	 	

  	 	document.getElementById('bc').innerHTML=reply;

  	 }

  	 	

  	 	 ax.connect('http://www.darkhorse.com.au/ajax/create_prod_sel.php','GET','',on_finish);

     return false;

  	

}



function create_prod_sel2(categ)

{

	

	

	 var ax = new XHConn();

  	 var on_finish = function(bx) {

  	 	 reply=bx.responseText;

  	 	

  	 	document.getElementById('bcl').innerHTML=reply;

  	 	

  	 }

  	 	

  	 	 ax.connect('http://www.darkhorse.com.au/ajax/create_prod_sel.php','GET','categ='+categ,on_finish);

     return false;

  	

}









function create_type_sel2(categ)

{

	

	

		 var ax = new XHConn();

  	 var on_finish = function(bx) {

  	 	 reply=bx.responseText;

  	 	document.getElementById('typesl').innerHTML=reply;

  	 }

  	 	

  	 	 ax.connect('http://www.darkhorse.com.au/ajax/create_type_sel2.php','GET','categ='+categ,on_finish);

     return false;

  	

}



function create_qty_sel2(categ)

{

	



	 var ax = new XHConn();

  	 var on_finish = function(bx) {

  	 	 reply=bx.responseText;

  	 	document.getElementById('qtysl').innerHTML=reply;

  	 	document.getElementById('pprice').innerHTML="<div class='text_bottom'>Your price will be show here!</div>";

  	 }

  	 	

  	 	 ax.connect('http://www.darkhorse.com.au/ajax/create_qty_sel2.php','GET','categ='+categ,on_finish);

     return false;

  	

}

var succes;



function create_qty_sel22(categ)

{

	
	succes=0;


	 var ax = new XHConn();

  	 var on_finish = function(bx) {

  	 	 reply=bx.responseText;
  	 	 succes=1;

  	 	document.getElementById('qtysl').innerHTML=reply;

  	// 	document.getElementById('pprice').innerHTML="<div class='text_bottom'>Your price will be show here!</div>";

  	 }

  	 	
	
  	 	 ax.connect('http://www.darkhorse.com.au/ajax/create_qty_sel2.php','GET','categ='+categ,on_finish);
  	 	 
  	 	

     return false;

  	

}






function show_price_div_succes()

{
//	alert('im');
	
	if(succes!=1)
	{
	//	alert('in');
		setTimeout('show_price_div_succes()',100);
		
	}
	if(succes!=1)
	return false;
	
	//alert(succes);
	types=document.getElementById('types').options[document.getElementById('types').selectedIndex].value;

	qtys=document.getElementById('qtys').options[document.getElementById('qtys').selectedIndex].value;

	art=document.getElementById('art').options[document.getElementById('art').selectedIndex].value;

	

//alert(qtys);

	

	 var ax = new XHConn();

  	 var on_finish = function(bx) {

  	 	 reply=bx.responseText;

  	 	document.getElementById('pprice').innerHTML=reply;

  	 }

  	 	

  	 	 ax.connect('http://www.darkhorse.com.au/ajax/show_price_div.php','GET','types='+types+'&qtys='+qtys+'&art='+art,on_finish);

     return false;

}




function show_price_div()

{

	types=document.getElementById('types').options[document.getElementById('types').selectedIndex].value;

	qtys=document.getElementById('qtys').options[document.getElementById('qtys').selectedIndex].value;

	art=document.getElementById('art').options[document.getElementById('art').selectedIndex].value;

	

//alert(qtys);

	

	 var ax = new XHConn();

  	 var on_finish = function(bx) {

  	 	 reply=bx.responseText;

  	 	document.getElementById('pprice').innerHTML=reply;

  	 }

  	 	

  	 	 ax.connect('http://www.darkhorse.com.au/ajax/show_price_div.php','GET','types='+types+'&qtys='+qtys+'&art='+art,on_finish);

     return false;

}







//back rotator var

arr = new Array(

["http://server-elcadia.com/diana_eu/darkhorse/images/banner_.png"],

["http://server-elcadia.com/diana_eu/darkhorse/images/banner_2.png"],


["http://server-elcadia.com/diana_eu/darkhorse/images/banner_3.png"],

["http://server-elcadia.com/diana_eu/darkhorse/images/banner_4.png"]


// no comma at the end of last index

);





var counter = 0;









//link rotator var

var imgsa = new Array("Two Sided, Full Color","Gloss / Silk","Double Sided Colour","Two Sided, Full Color");

var imgsaa = new Array("Business Cards","Booklets","Greeting Cards","Presentation Folders");

var imgsaaa = new Array("$55","$475","$180","$300");







var alta = new Array();





var currentAda = 0;

var imgCta = 4;





function backdiv()

{

	

	//back rotator func



	document.getElementById("rotate").style.background = 'transparent url('+ arr[counter][0] +') no-repeat';

	counter++; if (counter == arr.length)

	{counter = 0; } 



	//link rotator func





	 if (currentAda == imgCta) {

	    currentAda = 0;

	}

	  

	

	  document.getElementById('title').innerHTML = imgsa[currentAda];

	  document.getElementById('subtitle').innerHTML = imgsaa[currentAda];

		 document.getElementById('pricenr').innerHTML = imgsaaa[currentAda];

	  currentAda++;

	  

	 

	

	

	

	  

	

	



	  

	//time of rotation

	setTimeout('backdiv()', 7000)

	

}

