
function callResolution()
{
	if (/Safari[\/\s](\d+\.\d+)/.test(navigator.userAgent))
	{ 
		var fileref=document.createElement("link");
  		fileref.setAttribute("rel", "stylesheet");
  		fileref.setAttribute("type", "text/css");
  		fileref.setAttribute("href", "css/safari.css");
                if (typeof fileref!="undefined")
  			document.getElementsByTagName("head")[0].appendChild(fileref);               
	}	
}












var menu=function(){
	var t=15,z=50,s=6,a;
	function dd(n){this.n=n; this.h=[]; this.c=[]}
	dd.prototype.init=function(p,c){
		a=c; var w=document.getElementById(p), s=w.getElementsByTagName('ul'), l=s.length, i=0;
		for(i;i<l;i++){
			var h=s[i].parentNode; this.h[i]=h; this.c[i]=s[i];
			h.onmouseover=new Function(this.n+'.st('+i+',true)');
			h.onmouseout=new Function(this.n+'.st('+i+')');
		}
	}
	dd.prototype.st=function(x,f){
		var c=this.c[x], h=this.h[x], p=h.getElementsByTagName('a')[0];
		clearInterval(c.t); c.style.overflow='hidden';
		if(f){
			p.className+=' '+a;
			if(!c.mh){c.style.display='block'; c.style.height=''; c.mh=c.offsetHeight; c.style.height=0}
			if(c.mh==c.offsetHeight){c.style.overflow='visible'}
			else{c.style.zIndex=z; z++; c.t=setInterval(function(){sl(c,1)},t)}
		}else{p.className=p.className.replace(a,''); c.t=setInterval(function(){sl(c,-1)},t)}
	}
	function sl(c,f){
		var h=c.offsetHeight;
		if((h<=0&&f!=1)||(h>=c.mh&&f==1)){
			if(f==1){c.style.filter=''; c.style.opacity=1; c.style.overflow='visible'}
			clearInterval(c.t); return
		}
		var d=(f==1)?Math.ceil((c.mh-h)/s):Math.ceil(h/s), o=h/c.mh;
		c.style.opacity=o; c.style.filter='alpha(opacity='+(o*100)+')';
		c.style.height=h+(d*f)+'px'
	}
	return{dd:dd}
}();


function callResolution()
{
	if (/Safari[\/\s](\d+\.\d+)/.test(navigator.userAgent))
	{ 
		var fileref=document.createElement("link");
  		fileref.setAttribute("rel", "stylesheet");
  		fileref.setAttribute("type", "text/css");
  		fileref.setAttribute("href", "css/safari.css");
                if (typeof fileref!="undefined")
  			document.getElementsByTagName("head")[0].appendChild(fileref);               
	}	
}
//This function for the admin login validation
function admin_login_validation()
{
   
   if(document.getElementById('admin_username').value=="")
   {
	  alert("Please Enter Login user Name");
	  document.getElementById('admin_username').value="";
	  document.getElementById('admin_username').focus();
	  return false;
	
   }
   return true;
}
//function ends here



function PreloadImages(){
   imgUp = new Image();
   imgUp.src = '../images/UP.png';
   imgDown = new Image();
   imgDown.src = '../images/DOWN.png'; 
}

function toggleMenu(getMenu,getenuImage){

	PreloadImages();
	
    getMenu.style.display = (getMenu.style.display=="none") ? "" : "none";
    if (getMenu.style.display == "none") {
    	getenuImage.src=imgDown.src;
    }
    else {
    	getenuImage.src=imgUp.src;
    }
}


function update_element(container,url,parameter)
{
	//alert("parveen");
   var get_url=url+'?'+'cat_id='+parameter;
   //alert(get_url);
   new Ajax.Updater(container, get_url, { method: 'get' });	
}



function update_element1(container,url,parameter)
{
	//alert("parveen"+container);
   var get_url=url+'?'+'cat_id='+parameter;
   //alert(get_url);
   new Ajax.Updater(container, get_url, { method: 'get' });	
}











/*function open_div(disc,k,cat_value)
{
	
	var div_name='disc'+k;
 	var k=k+1;
	var div_name_new='disc'+k;
   document.getElementById(div_name).innerHTML="<div id='"+div_name+"'><table border=1 width=100%><tr class=tablesRowBG_2><td height=30 width=128 valign=top>Select Category</td><td colspan=3 valign=top><select name=category id=category onchange=update_element('sub_cat','sub_cat.php',this.value)><option value=''>---Select Category---</option> {foreach from=$cat_array key=myId item=i}<option value={$i.cat_id}>{$i.cat_name}</option></select></td><td width=20>&nbsp;</td></tr><tr class=tablesRowBG_2><td height=30 valign=top>&nbsp;</td><td colspan=3 valign=top>&nbsp;</td><td>&nbsp;</td></tr><tr class=tablesRowBG_2><td height=30 valign=top>Sub Category</td><td colspan=3 valign=top>Select Checkbox</td><td>&nbsp;</td></tr></table><br></div><div id='"+div_name_new+"'><a href='javascript:void(0)' onclick=open_div('disc',"+k+")>Add More Subcategory</a></div>";
}
*/
function check(container,url,parameter)
{
	 var get_url=url+'?'+'cat_id='+parameter;
     new Ajax.Updater(container, get_url, { method: 'get' });	
}
function check_user(container,url,parameter)
{
	 //alert(parameter);
	 var get_url=url+'?'+'user_id='+parameter;
     new Ajax.Updater(container, get_url,{ method: 'get' });
	 
}
function check_Reg_validation()
{
	if(document.getElementById('check').value==0)
	{
	return false;
	}
	if(document.getElementById('check').value==1)
	{
	return true;	
	}
}
//script for calendar starts here

var months = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
var daysInMonth = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
var days = new Array("S", "M", "T", "W", "T", "F", "S");

today = new getToday();	
var element_id;

function getDays(month, year) 
{
	// Test for leap year when February is selected.
	if (1 == month)
		return ((0 == year % 4) && (0 != (year % 100))) ||
			(0 == year % 400) ? 29 : 28;
	else
		return daysInMonth[month];
}

function getToday()
{
	// Generate today's date.
	this.now = new Date();
	this.year = this.now.getFullYear() ; // Returned year XXXX
	this.month = this.now.getMonth();
	this.day = this.now.getDate();
}

 
function newCalendar() 
{
	var parseYear = parseInt(document.all.year  [document.all.year.selectedIndex].text);
 
	var newCal = new Date(parseYear , document.all.month.selectedIndex, 1);
	var day = -1;
	var startDay = newCal.getDay();
	var daily = 0; 

	today = new getToday(); // 1st call
	if ((today.year == newCal.getFullYear() ) &&   (today.month == newCal.getMonth()))
	   day = today.day;
	// Cache the calendar table's tBody section, dayList.
	var tableCal = document.all.calendar.tBodies.dayList;

	var intDaysInMonth =
	   getDays(newCal.getMonth(), newCal.getFullYear() );

	for (var intWeek = 0; intWeek < tableCal.rows.length;  intWeek++)
		   for (var intDay = 0;
			 intDay < tableCal.rows[intWeek].cells.length;
			 intDay++)
	 {
		  var cell = tableCal.rows[intWeek].cells[intDay];

		  // Start counting days.
		  if ((intDay == startDay) && (0 == daily))
			 daily = 1;

		  // Highlight the current day.
		  cell.style.color = (day == daily) ? "red" : "";
		  if(day == daily)
		  {
				document.all.todayday.innerText= "Today: " +  day + "/" + 
					(newCal.getMonth()+1) + "/" + newCal.getFullYear() ;
		  }
		  // Output the day number into the cell.
		  if ((daily > 0) && (daily <= intDaysInMonth))
			 cell.innerText = daily++;
		  else
			 cell.innerText = "";
	   }

}
	  
	 function getTodayDay()
	 {
			    document.all[element_id].value = today.day + "/" + (today.month+1) + 
					"/" + today.year; 
		        //document.all.calendar.style.visibility="hidden";
				document.all.calendar.style.display="none";
				document.all.year.selectedIndex =100;   
	            document.all.month.selectedIndex = today.month; 
	 }
 
        function getDate() 
		 {
            // This code executes when the user clicks on a day
            // in the calendar.
            if ("TD" == event.srcElement.tagName)
               // Test whether day is valid.
               if ("" != event.srcElement.innerText)
			   { 
				 var mn = document.all.month.selectedIndex+1;
    			 var Year = document.all.year [document.all.year.selectedIndex].text;
				 document.all[element_id].value=event.srcElement.innerText+"/"+mn +"/"  +Year;
		         //document.all.calendar.style.visibility="hidden";
				 document.all.calendar.style.display="none";
			 }
		 }
 
function GetBodyOffsetX(el_name, shift)
{
	var x;
	var y;
	x = 0;
	y = 0;

	var elem = document.all[el_name];
	do 
	{
		x += elem.offsetLeft;
		y += elem.offsetTop;
		if (elem.tagName == "BODY")
			break;
		elem = elem.offsetParent; 
	} while  (1 > 0);

	shift[0] = x;
	shift[1] = y;
	return  x;
}	

function SetCalendarOnElement(el_name)
{
	if (el_name=="") 
	el_name = element_id;
	var shift = new Array(2);
	GetBodyOffsetX(el_name, shift);
	document.all.calendar.style.pixelLeft  = shift[0]; //  - document.all.calendar.offsetLeft;
	document.all.calendar.style.pixelTop = shift[1] + 25 ;
}
	  
 	  
	           
function ShowCalendar(elem_name)
{
		if (elem_name=="")
		elem_name = element_id;

		element_id	= elem_name; // element_id is global variable
		newCalendar();
		SetCalendarOnElement(element_id);
		//document.all.calendar.style.visibility = "visible";
		document.all.calendar.style.display="inline";
}

function HideCalendar()
{
	//document.all.calendar.style.visibility="hidden";
	document.all.calendar.style.display="none";
}

function toggleCalendar(elem_name)
{
	//if (document.all.calendar.style.visibility == "hidden")
	if(document.all.calendar.style.display=="none")
		ShowCalendar(elem_name);
	else 
		HideCalendar();
}

function  output_month()
{
// Output months into the document.
		// Select current month.
for (var intLoop = 0; intLoop < months.length; intLoop++)
document.write("<OPTION " +	(today.month == intLoop ? "Selected" : "") + ">" + months[intLoop]);	
}

function output_year()
{
	// Output years into the document.
		// Select current year.
		for (var intLoop = 1900; intLoop < 2028; intLoop++)
			document.write("<OPTION " + (today.year == intLoop ? "Selected" : "") + ">" + intLoop);
}
function output_day()
{
	// Output days.
	for (var intLoop = 0; intLoop < days.length; intLoop++)
		document.write("<TD>" + days[intLoop] + "</TD>");
}

function output_weeks()
{
	for (var intWeeks = 0; intWeeks < 6; intWeeks++)
	{
		document.write("<TR>");
		for (var intDays = 0; intDays < days.length; intDays++)
			document.write("<TD></TD>");
		document.write("</TR>");
	}
}

function IsNumeric(strString)
   //  check for valid numeric strings	
   {
   var strValidChars = "0123456789";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
   }






function HandleError(val)
{
	
	var qtyid = 'qty' + val;
	//alert(qtyid);
	var q = document.getElementById(qtyid).value
	
	//alert(q);
	if(IsNumeric(q)){
    cart(val,q);
    return true;
    }else{
    return false;
    }
}


function cart(id, qty)
{
	var qty1 =qty;	
	//var get_url="cart.php?task=Update&proID="+id+"&qty="+qty1; 
	window.location.href="cart.php?task=Update&product_id="+id+"&intQuant="+qty1; 
}


function clearCart(){
var agree = confirm('Do you really want to clear Shopping Cart!!!!');
if(agree){
	window.location.href="cart.php?task=Clear";
    return true;
}
else{
return false;
}
}



function confirmation(id){

//alert("parveen"+id);
var agree = confirm('Do you really want to remove this item!!!!');
if(agree){ 
	window.location.href="cart.php?task=Delete&product_id="+id;

return true;
}else{
return false;}
}



function delete_order(order_no){

//alert("parveen"+order_no);
var agree = confirm('Do you really want to Delete this Order!!!!');
if(agree){ 
//alert("delete this");
	window.location.href="orddet.php?delete=Delete&order_no="+order_no;

return true;
}else{
return false;}
}


function delete_ship_order(order_no){

//alert("parveen"+order_no);
var agree = confirm('Do you really want to Delete this Shipped Order!!!!');
if(agree){ 
//alert("delete this");
	window.location.href="orddet.php?Ship_delete=Delete&order_no="+order_no;

return true;
}else{
return false;}
}







function confirmverify1(order_no){

var agree = confirm('Are You Sure want to make it Unpaid Order!!!!');
if(agree){ 

	window.location.href="orddet.php?unpaid=yes&order_no="+order_no;

return true;
}else{
return false;}
}


function order_submit(order_no){

window.location.href="orddet.php?change_status=yes&order_no="+order_no;


}




function ff(){

if(document.order_form.a.checked)
{
	
document.order_form.S_name.value     = document.order_form.name.value;
document.order_form.S_city.value     = document.order_form.city.value;
document.order_form.S_state.value    = document.order_form.state.value;
document.order_form.S_zip.value      = document.order_form.zip.value;
document.order_form.S_phone.value    = document.order_form.phone.value;
document.order_form.S_address.value  = document.order_form.address.value;
 
}
else
{
document.order_form.S_name.value = "";
document.order_form.S_city.value = "";
document.order_form.S_state.value = "";
document.order_form.S_zip.value = "";
document.order_form.S_phone.value = "";
document.order_form.S_address.value = "";
 
}
 
}


function order_submit(order_no){

window.location.href="orddet.php?change_status=yes&order_no="+order_no;


}

function gg(o)
{
	
	window.location.href="order_details1.php?order_id="+o;
}


