function changeSizes() {
 
   $.ajax({
			method: "get",url: siteUrl+"/index.php",data: "mode=apparelSizeList&color="+$("#color").val(),
			beforeSend: function(){$("#loading1").show("fast");}, //show loading just when link is clicked
			complete: function(){ $("#loading1").hide("fast");}, //stop showing loading when the process is complete
			success: function(html){ //so, if data is retrieved, store it in html
			$("#changeSize").show("slow"); //animation
			
			$("#changeSize").html(html); //show the html inside .content div
			 $("#showButtons").html('');
			}
		}); //close $.ajax(
	
	
	 
}


function changeSizes1() {
 
   $.ajax({
			method: "get",url: siteUrl+"/index.php",data: "mode=apparelSizeList1&color="+$("#color").val(),
			beforeSend: function(){$("#loading1").show("fast");}, //show loading just when link is clicked
			complete: function(){ $("#loading1").hide("fast");}, //stop showing loading when the process is complete
			success: function(html){ //so, if data is retrieved, store it in html
			$("#changeSize").show("slow"); //animation
			
			$("#changeSize").html(html); //show the html inside .content div
			 $("#showButtons").html('');
			}
		}); //close $.ajax(
	
	
	 
}

function changeSizes2() {
 
   $.ajax({
			method: "get",url: siteUrl+"/index.php",data: "mode=apparelSizeList2&color="+$("#color").val(),
			beforeSend: function(){$("#loading1").show("fast");}, //show loading just when link is clicked
			complete: function(){ $("#loading1").hide("fast");}, //stop showing loading when the process is complete
			success: function(html){ //so, if data is retrieved, store it in html
			$("#changeSize").show("slow"); //animation
			
			$("#changeSize").html(html); //show the html inside .content div
			 $("#showButtons").html('');
			}
		}); //close $.ajax(
	
	
	 
}

function changeSizes3() {
	alert("hello");
 
   $.ajax({
			method: "get",url: siteUrl+"/index.php",data: "mode=generalSizeList&color="+$("#color").val(),
			beforeSend: function(){$("#loading1").show("fast");}, //show loading just when link is clicked
			complete: function(){ $("#loading1").hide("fast");}, //stop showing loading when the process is complete
			success: function(html){ //so, if data is retrieved, store it in html
			$("#changeSize").show("slow"); //animation
			
			$("#changeSize").html(html); //show the html inside .content div
			 $("#showButtons").html('');
			}
		}); //close $.ajax(
	
	
	 
}

function checkStock() { 
  
   $.ajax({
			method: "get",url: siteUrl+"/index.php",data: "mode=checkStockAvailable&size="+$("#size").val()+"&color="+$("#colorID").val(),
			beforeSend: function(){$("#loading1").show("fast");}, //show loading just when link is clicked
			complete: function(){ $("#loading1").hide("fast");}, //stop showing loading when the process is complete
			success: function(html){ //so, if data is retrieved, store it in html
			$("#showButtons").show("slow"); //animation
			
			$("#showButtons").html(html); //show the html inside .content div
			}
		}); //close $.ajax(
	
	
	 
}

function checkStock2(){



var length = document.cart.stock.length;


if(length){
	//alert(document.cart.quantity[0].value);
//alert(document.cart.stock[0].value);
		for(i=0;i<length;i++){
		
					if((parseInt(document.cart.quantity[i].value) > parseInt(document.cart.stock[i].value))||(parseInt(document.cart.quantity[i].value) <= 0))
					{
					/*alert("Quantity can not exceed available stock of "+document.cart.stock[i].value+ " for Product Code " +document.cart.proId1[i].value + " of size "+document.cart.sizes[i].value);*/
					
					if(parseInt(document.cart.quantity[i].value) <= 0)
{
	alert("Sorry, Your Quantity must be in positive");
}
else
{
	
					alert("Sorry, Your Quantity is more then stock available");
}
					document.cart.quantity[i].focus;
					return false;
					}
		}
}
else if((parseInt(document.cart.quantity.value) > parseInt(document.cart.stock.value))||(parseInt(document.cart.quantity.value) <= 0))	{

/*alert("Quantity can not exceed available stock of "+document.cart.stock.value+ " for Product Code " +document.cart.proId1.value + " of size "+document.cart.sizes.value);*/
if(parseInt(document.cart.quantity.value) <= 0)
{
	alert("Sorry, Your Quantity must be in positive");
}
else
{
alert("Sorry, Your Quantity is more then stock available");
}
document.cart.quantity.focus;
return false;
	
}

document.cart.submit();
}


function checkStock1(){





//var length = document.cart.stock.length;



//if(length){

//alert(document.cart.quantity[0].value);

//alert(document.cart.stock[0].value);





document.cart.submit();

} 


function changeMode(mode)
{
	var length = document.cart.stock.length;


if(length)
{
	//alert(document.cart.quantity[0].value);
//alert(document.cart.stock[0].value);
		for(i=0;i<length;i++)
		{
		
					if((parseInt(document.cart.quantity[i].value) > parseInt(document.cart.stock[i].value))||(parseInt(document.cart.quantity[i].value) <= 0))
					{
					/*alert("Quantity can not exceed available stock of "+document.cart.stock[i].value+ " for Product Code " +document.cart.proId1[i].value + " of size "+document.cart.sizes[i].value);*/
					
					if(parseInt(document.cart.quantity[i].value) <= 0)
{
	alert("Sorry, Your Quantity must be in positive");
}
else
{
	
					alert("Sorry, Your Quantity is more then stock available");
}
					document.cart.quantity[i].focus;
					return false;
					}
		}
}
else if((parseInt(document.cart.quantity.value) > parseInt(document.cart.stock.value))||(parseInt(document.cart.quantity.value) <= 0))	
{

/*alert("Quantity can not exceed available stock of "+document.cart.stock.value+ " for Product Code " +document.cart.proId1.value + " of size "+document.cart.sizes.value);*/
if(parseInt(document.cart.quantity.value) <= 0)
{
	alert("Sorry, Your Quantity must be in positive");
}
else
{
alert("Sorry, Your Quantity is more then stock available");
}
document.cart.quantity.focus;
return false;
	
}

	
	
		//alert(f1);
	//if(document.cart.country.value==''){
		//alert("Please select country to proceed..");
		//return false;
		//}	
	window.document.cart.mode.value = "performAction";
	window.document.cart.process.value = "Checkout";
	window.document.cart.submit();
}
function changeMode1(mode)
{
		
	if(mode=='continue')	
	document.cart.mode.value = "continue";
	else
	document.cart.mode.value = "performAction";
	
	document.cart.submit();
}

function editDeleteDeliveryAddress(mod,pro,id)
{
	var form = document.form1;
	
	
	form.process.value = pro;
	form.mode.value = mod;
	
	form.id.value = id;

	form.submit();


}

var xmlHttp

function stateChanged() 
{ 

}
function GetXmlHttpObject()
{
var xmlHttp=null;
try
 {
 // Firefox, Opera 8.0+, Safari
 xmlHttp=new XMLHttpRequest();
 }
catch (e)
 {
 //Internet Explorer
 try
  {
  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  }
 catch (e)
  {
  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
 }
return xmlHttp;
}
function changeModeToOrder(f1){
	
	f1.mode.value = "placeOrder";
		
			
	
}


function showNextPage(path, extraParams){

	var redirectURL = path + extraParams + "page=" + document.getElementById('pageSelect').value;
	
	window.location.href = redirectURL;
}


function showUser1(str,w)
{ 
var total=parseInt(document.cart.totalprice.value);

xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 } 
var url= siteUrl + "/classes/getweight.php"
url=url+"?country="+str
url=url+"&weight="+w
url=url+"&total="+total

xmlHttp.onreadystatechange=stateChanged2 
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}

function stateChanged2() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
 //alert(document.cart.totalprice.value);
 //alert(document.getElementById("grandTotal").innerHTML);
 document.getElementById("grandTotal").innerHTML=xmlHttp.responseText 
 } 
}


// pop ups


/***************************/
//@Author: Adrian "yEnS" Mato Gondelle
//@website: www.yensdesign.com
//@email: yensamg@gmail.com
//@license: Feel free to use it, but keep this credits please!					
/***************************/

//SETTING UP OUR POPUP
//0 means disabled; 1 means enabled;

var popupStatus = 0;

//loading popup with jQuery magic!
function loadPopup(){
	//loads popup only if it is disabled
	if(popupStatus==0){
		$("#backgroundPopup").css({
			"opacity": "0.7"
		});
		$("#backgroundPopup").fadeIn("slow");
		$("#popupContact").fadeIn("slow");
		popupStatus = 1;
		
	}
	
}

//disabling popup with jQuery magic!
function disablePopup(){
	
	//disables popup only if it is enabled
	if(popupStatus==1){
		$("#backgroundPopup").fadeOut("slow");
		$("#popupContact").fadeOut("slow");
		popupStatus = 0;
	}
}

//centering popup
function centerPopup(){
	//request data for centering
	if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    var windowWidth = document.documentElement.clientWidth;
    	var windowHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
      var windowWidth  = document.body.clientWidth;
    var windowHeight = document.body.clientHeight;
  }

	
	
	//var windowWidth = document.documentElement.clientWidth;
	//alert(windowWidth);
	//var windowHeight = document.documentElement.clientHeight;
	//var windowHeight = 566;
	//var windowWidth = 1003;
	
	var popupHeight = $("#popupContact").height();
	var popupWidth = $("#popupContact").width();
	//centering
	$("#popupContact").css({
		"position": "absolute",
		//"top": windowHeight/2-popupHeight/2,
		//"left": windowWidth/2-popupWidth/2
		"top": windowHeight/2-popupHeight/2,
		"left": windowWidth/2-popupWidth/2
	});
	//only need force for IE6
	
	$("#backgroundPopup").css({
		"height": windowHeight
	});
	
}


//CONTROLLING EVENTS IN jQuery


function confirmRequest1(url,width1,height1,id){
	
	var id1 = "#"+id;
	
	$("#Express").click(function(){
		//centering with css
		centerPopup();
		//load popup
		loadPopup();
	});
	
		document.getElementById("cframe1").src=url
}



var oXHR = null;



function sendRequest(f,mode){

mode= typeof(mode) != 'undefined' ? mode : '';

var oForm = f ;

if(typeof(f)=="object"){
var sBody = getRequestBody(f);
var script = oForm.action;
}
else
var script = f;


if(!oXHR){

var oXHR = createXHR();

} 


document.getElementById("list").innerHTML = '<center><p><p><img src="'+siteUrl+'/images/loading1.gif" width="100" height="100" /></center>';

oXHR.open("post",script,true);


oXHR.setRequestHeader("Content-Type","application/x-www-form-urlencoded");

oXHR.onreadystatechange = function(){
									
	
									if(oXHR.readyState == 4){
											//alert(oXHR.status)
											//alert(oXHR.responseText)
											if(oXHR.status == 200){
												
												//alert(oXHR.responseText)
													if(mode=='protectPhoto' || mode=='changePicture'){
													//alert(oXHR.responseText)
													document.getElementById("status").innerHTML = oXHR.responseText;
													
													}
											
												 else
												 document.getElementById("list").innerHTML = oXHR.responseText;
												 
											}else{
												if(mode == 'search'){
										document.getElementById("list").innerHTML = "An error has ocurred: "+ oXHR.tatusText;
												document.searchForm.searchValue.focus();
												}
												
												else
												 document.getElementById("list").innerHTML = "An error has ocurred: "+ oXHR.tatusText;
											}
									
									}

							};
							
	oXHR.send(sBody);	
}



function encodeNameAndValue(sName, sValue){

var sParam = encodeURIComponent(sName);

sParam += "=";

sParam += encodeURIComponent(sValue);
return sParam;
}

function createXHR(){

	if(typeof XMLHttpRequest != "undefined"){
	
		return new XMLHttpRequest();
	}
	else if(window.ActiveXObject){

			var aVersions = ["MSXML2.XMLHttp.6.0", "MSXML2.XMLHttp.3.0"];

			for(var i=0; i<aVersions.length; i++){
		
					try{
					   var oXHR = new ActiveXObject(aVersions[i]);
					   return oXHR;
					}catch(oError){}
			
	
	
			}
	}
}

function getRequestBody(f){

	var aParams = new Array();
	var oForm = f;
	for(var i=0;i<oForm.elements.length; i++){
	
		var oField = oForm.elements[i];
		
			switch(oField.type){
			
				case "button":
				case "submit":
				case "reset":
						break;
						
				case "checkbox":		
				case "radio":
						if(!oField.checked){
						break;
						}
				case "text":
				case "select-one":
				case "textarea":
				case "hidden":
				case "password":	
						aParams.push(encodeNameAndValue(oField.name, oField.value));
						break;
						
				default:
							
			
			
			}
	}
	
	return aParams.join("&");

}






function confirmRequest(f,w,h){
	
	if(confirm("Do you realy want to process the request?"))	{
	loadwindow(f,w,h);
		
	}
}


var xmlHttp
function checkEmailAvailable(email)
{ 

xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 } 
var url=siteUrl+"/checkEmail.php"
url=url+"?email="+email

document.getElementById("username").innerHTML = '<img src="'+siteUrl+'/images/loading.gif"  />';

xmlHttp.onreadystatechange=stateChanged 
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}

function stateChanged() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
 
		if(xmlHttp.responseText!="1" && xmlHttp.responseText!=true){
		document.registerMember.email.value='';
		 document.getElementById("username").innerHTML = xmlHttp.responseText;
		 } 
		 else 
		 document.getElementById("username").innerHTML = "<img src='"+siteUrl+"/images/admin/tick.png' align='absmiddle'> Email available.";
}
}
function GetXmlHttpObject()
{
var xmlHttp=null;
try
 {
 // Firefox, Opera 8.0+, Safari
 xmlHttp=new XMLHttpRequest();
 }
catch (e)
 {
 //Internet Explorer
 try
  {
  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  }
 catch (e)
  {
  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
 }
return xmlHttp;
}


function submitSearch(f1){
	//document.searchForm.catID.value = "test";
	   $.ajax({
			method: "get",url: siteUrl+"/search/index.php",data: "mode=getCategoryData&searchCategory="+$("#searchCategory").val(),
			//beforeSend: function(){$("#loading1").show("fast");}, //show loading just when link is clicked
			//complete: function(){ $("#loading1").hide("fast");}, //stop showing loading when the process is complete
			success: function(html){ //so, if data is retrieved, store it in html
			$("#hiddenFields").show("slow"); //animation
			arr = html.split(",");
			count = arr.length;
			//alert(arr[0]);
			document.searchForm.categoryName.value = arr[0];
			document.searchForm.catID.value = arr[1];
			document.searchForm.ParentID.value = arr[2];
			document.searchForm.mode.value = "search1";
			//$("#categoryName").val(arr[0]);
			//document.searchForm.catID.value = "test";
			/*window.document.searchForm.categoryName.value = arr[0];
			window.document.searchForm.catID.value = arr[1];
			window.document.searchForm.ParentID.value = arr[2];*/
			
			//$("#hiddenFields").html(html); //show the html inside .content div
			f1.submit();
			}
		}); //close $.ajax(
	
//	f1.submit();
	
}