var ClickedImage,ClickedImageID,ClickedIconImage,ImageCheck=0,IcomImageCounter=0;
function opacity(id, opacStart, opacEnd, millisec)
{
    var speed = Math.round(millisec / 100);
    var timer = 0;
    if(opacStart > opacEnd)
    {
        for(i = opacStart; i >= opacEnd; i--)
        {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    }
    else if(opacStart < opacEnd)
    {
        for(i = opacStart; i <= opacEnd; i++)
        {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    }
}

function changeOpac(opacity, id)
{
    var object = document.getElementById(id).style;
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")  ";
}

function showLoader()
{
	document.getElementById('wait').style.display='inline';
}

function hideLoader()
{
	document.getElementById('wait').style.display='none';
}

function showLoader1()
{
	$('#wait').show('slow');
	$('#container').fadeTo(200, 0.5);
}

function hideLoader1()
{
	$('#wait').hide('slow');
}

function loadCategory(catid,classid)
{
	showLoader();// load images
	changeOpac(23,'container');// set opacity
	changeClass(classid);// change selection classs
	$('#categorydiv').show('slow');
	$('#categorydiv').load('ajaxCategoryPage.php?cat_id='+catid);
	setTimeout("changeOpac(100,'container');", 500);
	setTimeout("hideLoader();", 500);
	
	
}


function LoadCatJQ(CatID,CatImages){
	showLoader();// load images
	changeOpac(23,'container');// set opacity
	
	var texthtml=$("#"+CatImages).html();
	function show()
	{
		$(".A4-back_matsheet1").html('');
		$(".A4-back_matsheet1").html(texthtml);
	}
	
	 $('#ajaxProductPage').load('ajaxProducts1.php',{cat_id:CatID,CatImageHTML:CatImages,cat_select:1},function(){
		 	$('#categoryImages').load('ajaxCategoryImages.php?cat_id='+CatID,null,show);
		 	$('#cat_select').val(1);
			setTimeout("changeOpac(100,'container');", 100);
			setTimeout("hideLoader();", 100);
			
		    $(".A4-back_matsheet1").html('');
			$(".A4-back_matsheet1").html(texthtml);
	 });
	 
	$("#CatBox"+CatID).addClass("A4-box1_Selected");
	
	$('.A4-box1').click(function(){
		   $('.A4-box1_Selected').removeClass('A4-box1_Selected');
		   $(this).addClass('A4-box1_Selected');
	});
}

function fadeBrowser()
{
	showLoader();// load images
	changeOpac(23,'container');// set opacity
}

var scrolling = null;
function scroll_up()
{
     var d = document.getElementById('scroller');
     d.scrollTop = d.scrollTop - 50;
}
 
 function scroll_down()
 {
     var d = document.getElementById('scroller');
     d.scrollTop = d.scrollTop + 50;
 }

 function ChangePrice(val,PriceDiv,Price1,Price5,Price10,Price25,Price50,Price75,Price100,Price150,Price200)//One And Only Function For Price Calculation
 {
 	var Oldprice;
 	
 	if(val < 5){HoldPrice=Price1;Oldprice=val*Price1;}
 	if(val >= 5 && val < 10){HoldPrice=Price5;Oldprice=val*Price5;}
 	if(val >= 10  && val < 25){HoldPrice=Price10;Oldprice=val*Price10;}
 	if(val >= 25  && val < 50){HoldPrice=Price25;Oldprice=val*Price25;}
 	if(val >= 50  && val < 75){HoldPrice=Price50;Oldprice=val*Price50;}
 	if(val >= 75  && val < 100){HoldPrice=Price75;Oldprice=val*Price75;}
 	if(val >= 100 && val < 150){HoldPrice=Price100;Oldprice=val*Price100;}
 	if(val >= 150 && val < 200){HoldPrice=Price150;Oldprice=val*Price150;}
 	if(val >= 200){HoldPrice=Price200;Oldprice=val*Price200;}

 	var result = Oldprice.toFixed(2); // result will equal 10.00
 	$("#"+PriceDiv+"Single").val(HoldPrice);
 	$("#"+PriceDiv).val(result);
 }
 
 function ChangePrice1(val,Price1,Price5,Price10,Price25,Price50,Price75,Price100,Price150,Price200)//One And Only Function For Price Calculation
 {
 	var Oldprice;
 	var HoldPrice;
 	if(val < 5){HoldPrice=Price1;Oldprice=val*Price1;}
 	if(val >= 5 && val < 10){HoldPrice=Price5;Oldprice=val*Price5;}
 	if(val >= 10  && val < 25){HoldPrice=Price10;Oldprice=val*Price10;}
 	if(val >= 25  && val < 50){HoldPrice=Price25;Oldprice=val*Price25;}
 	if(val >= 50  && val < 75){HoldPrice=Price50;Oldprice=val*Price50;}
 	if(val >= 75  && val < 100){HoldPrice=Price75;Oldprice=val*Price75;}
 	if(val >= 100 && val < 150){HoldPrice=Price100;Oldprice=val*Price100;}
 	if(val >= 150 && val < 200){HoldPrice=Price150;Oldprice=val*Price150;}
 	if(val >= 200){	HoldPrice=Price200;Oldprice=val*Price200;}

 	var result = Oldprice.toFixed(2); // result will equal 10.00
	$("#productRPrice").val(HoldPrice);
	$("#productExPrice").val(result);

 }

 function ChangeColorOver(imgColId,imgCounter)
 {
 	
 }

 function stop_scroll()
 {
     window.clearTimeout(scrolling);
 }

 function changeClass(id)
 {
 	document.getElementById('custom').className='custom';
 	document.getElementById('address').className='address';
 	document.getElementById('media').className='media';
 	document.getElementById('circular').className='circular';
 	document.getElementById('multipurpose').className='multipurpose';
 	document.getElementById('shipping').className='shipping';
 	document.getElementById('parcel').className='parcel';
 	document.getElementById(id).className=id+"Sel";
 }

 function showLoginDiv()
 {
	document.getElementById('DivLogin').style.display='inline';
	document.getElementById('DivForget').style.display='none';
	showLoginDiv1();
 }

 function HidLoginDiv()
 {
	document.getElementById('DivLogin').style.display='none';
 }
 
 function DivForget()
 {
	document.getElementById('DivForget').style.display='inline';
	document.getElementById('DivLogin').style.display='none';
 }

 function showLoginDiv1()
 {
	document.getElementById('DivLogin1').style.display='inline';
	document.getElementById('DivForget1').style.display='none';
 }

 function HidLoginDiv1()
 {
	document.getElementById('DivLogin1').style.display='none';
 }
 
 function DivForget1()
 {
	document.getElementById('DivForget1').style.display='inline';
	document.getElementById('DivLogin1').style.display='none';
 }

function loadCategoryImages(catid)
{
	showLoader();// load images
	changeOpac(23,'container');// set opacity
	loadDynData('ajaxCategoryImages.php','cat_id='+catid,'categoryImages');// ajax load

	document.getElementById('CategoryID').value=catid;
	productAjax();//execute re again ajax after some pause
}

 function productAjax()
 {
 	//setTimeout ("productAjaxPause()", 500);
 }

 function productAjaxPause()
 {
 	//loadDynData('ajaxProducts1.php','cat_id='+document.getElementById('CategoryID').value,'ajaxProductPage');
 }

 function delCartItem(pid)
 {
 	if(confirm('Are you sure you want to Delete ?'))
 	{
 		fadeBrowser();
 		loadDynData('ajax/ajaxCartDetails.php','cmd=cartUpdateAjax&product_id='+pid+'&qty=0','CartDiv');
 	}
 	else
 	{
 		return false;
 	}
 }

 function ChangeRoundImages(ProductID,DivID,ImgColorID,ImageName,ProdDIV,ProductName,QuantityVal,PriceDiv,Price1,Price5,Price10,Price25,Price50,Price75,Price100,Price150,Price200,Looper)
 {
 		//alert(Price1);
 		$("#ProductIDGT"+Looper).val(ProductID);
		$("#Price1GT"+Looper).val(Price1);
		$("#Price5GT"+Looper).val(Price5);
		$("#Price10GT"+Looper).val(Price10);
		$("#Price25GT"+Looper).val(Price25);
		$("#Price50GT"+Looper).val(Price50);
		$("#Price75GT"+Looper).val(Price75);
		$("#Price100GT"+Looper).val(Price100);
		$("#Price150GT"+Looper).val(Price150);
		$("#Price200GT"+Looper).val(Price200);

 		ChangePrice(QuantityVal,PriceDiv,Price1,Price5,Price10,Price25,Price50,Price75,Price100,Price150,Price200)//For Price Adjustments w.r.t Colors
 			var productTitle = ProductName;
 			var PTitle = productTitle.split("-");
			
 			
 			showLoader();// load images
			changeOpac(23,'container');// set opacity
			$("#"+DivID).html("<img src='images/productimages/"+ImageName+"' alt='' border='0' />");
			$("#"+ProdDIV).html(ProductName);
			$("#protitle_name"+Looper).html(PTitle[0]);
			setTimeout("changeOpac(100,'container');", 500);
			setTimeout("hideLoader();", 500);
 }

 function Change_PriceCart(Qty,Price1,Price5,Price10,Price25,Price50,Price75,Price100,Price150,Price200)
 {
 	//alert(Price50);
 	var Rprice=ChangePrice1(Qty,Price1,Price5,Price10,Price25,Price50,Price75,Price100,Price150,Price200);
 }
 
 function ChangeCompTab(DivIdchange,comptext){
 	
 	//alert(comptext);
 	var text=comptext;
 	/*alert(DivIdchange);*/
 	//$("#"+DivIdchange).html(comptext);
 	
 	//$('#'+DivIdchange).load('ajax/ajax_showcomp.php?text='+comptext,null,show);
 	//$('#'+DivIdchange).load('ajax/ajax_showcomp.php?text='+text);
 	/*function sjow()(){
 		
 	}*/
 	$('#'+DivIdchange).load('ajax/ajax_showcomp.php',{text:text });
 	//alert('Donee');
 }
 
 function Qeemat_View(FDName,SDName,DvId){
 	$("#"+FDName+DvId).hide(1000);
 	$("#"+DName+DvId).hide(1000);
 }
 
 function ChangeClickIconImage(iconImage,TargetDiv,iconImageID,Counter){
    if(ClickedImage!='' && ImageCheck!=0 && IcomImageCounter==Counter){
    	$("#"+ClickedImage).html("<img id='"+ClickedImageID+"' src='images/productimages/"+ClickedIconImage+".gif' alt='' border='0' style='cursor:pointer;'/>");
 		$("#"+TargetDiv).html("<img id='"+TargetDiv+"' src='images/productimages/"+iconImage+"-over.gif' alt='' border='0' style='cursor:pointer;'/>");
    }
    else
    {
 		$("#"+TargetDiv).html("<img id='"+TargetDiv+"' src='images/productimages/"+iconImage+"-over.gif' alt='' border='0' style='cursor:pointer;'/>");
    }
 	ImageCheck=1;
 	ClickedImage=TargetDiv;
	ClickedIconImage=iconImage;
	ClickedImageID=iconImageID;
	IcomImageCounter=Counter;
 }

 function ChangeIconImage(iconImage,TargetDiv){
 	var srcc='images/productimages/'+iconImage+'.gif';
	var src = srcc.match(/[^\.]+/) + "-over.gif ";
    $("#"+TargetDiv).attr("src", src);
 }

 function ChangeMQty(Qtyy,tval){
 	//alert(Qtyy);
 	$('#'+Qtyy).val(tval);
 }
 
 function Save_Product(){
 	
	$('#overlay').fadeOut(function(){ $(this).remove(); });
	$('.prettyPopin').fadeOut(function(){ $(this).remove(); callback() });
	$('#updateto').load('shopping.php',{action: 'addToBasket_Poppin',productID:$('#productID').val(),productQty:$('#productQty').val(),productPrice:$('#productPrice').val()});
	
 }

 function callback(){
 	$(".shoppp").load('minicart.php');
 	$("#show_buttons").show('slow');
 }

 function ReverseChangeIconImage(iconImage,TargetDiv){
 	var srcc='images/productimages/'+iconImage;
 	var src = srcc.replace("over", "");
    $("#"+TargetDiv).attr("src", src);
 }

 function Plus_Qty(Plus_Qty,PriceDiv,Price1,Price5,Price10,Price25,Price50,Price75,Price100,Price150,Price200){
 	var newVal=parseFloat($("#"+Plus_Qty).val())+1;
 	
 	
 	if (newVal < 1000) {
 		$("#"+Plus_Qty).val(newVal);
 		ChangePrice(newVal,PriceDiv,Price1,Price5,Price10,Price25,Price50,Price75,Price100,Price150,Price200)//For Price Adjustments w.r.t Colors
 	}
 	
 }

 function Min_Qty(Plus_Qty,PriceDiv,Price1,Price5,Price10,Price25,Price50,Price75,Price100,Price150,Price200){
 	var OldValue=parseFloat($("#"+Plus_Qty).val());
 	var newVal=parseFloat($("#"+Plus_Qty).val())-1;
 	if (newVal >= 1) {
 		$("#"+Plus_Qty).val(newVal);
 		ChangePrice(newVal,PriceDiv,Price1,Price5,Price10,Price25,Price50,Price75,Price100,Price150,Price200)//For Price Adjustments w.r.t Colors
 	}
 }

 function getCatImage(CatImages){
 	//alert('Hello');
 }
 
 function hideall(){
 	$(".fake").each(function(){
		$('.fake').hide();
	});
 }

 function show_thumbnail(DivId,ShowImg,fakeDiv){
	document.getElementById(DivId).style.display='inline';
 }
 
 function vanish_div(DivId){
 	 		$('#'+DivId).hide();
 }
 
 function SlideUp(SlideDivID){
 	
 }

function isNumberKey(evt){
	var charCode = (evt.which) ? evt.which : event.keyCode;
	if(charCode > 95 && charCode < 106 )
	{
		return true;
	}
	else if (charCode > 33 && (charCode < 48 || charCode > 57) )
	{
		return false;
	}
	else
	{
		return true;
	}
}

	function selTab()
	{
		document.getElementById('tab1').className='drop-down-button';
		document.getElementById('tab2').className='menu-btn';
		document.getElementById('tab3').className='menu-btn';
		document.getElementById('tab4').className='menu-btn';
		document.getElementById('ViewFreeTemplate').className='menu-selected';
		
	}

