// Copyright (c) Alcusoft 2002,
// All rights reserved
//
// All kind of unauthorized use and
// copying of the material on this
// site is prohibited.


var daysofmonths = new Array();

daysofmonths[0] = new Array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,0);
daysofmonths[1] = new Array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,0);
daysofmonths[2] = new Array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,0);
daysofmonths[3] = new Array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,0);


function setPage(page) {
	document.cookie = 'productPage=' + page;
}

function setCartMode(mode) {
	document.cookie = 'caobjmode=' + mode;
}

function setLeftMenu() {
	document.cookie = 'left_frame=' + window.location.href;
}

function setProductPage() {
	document.cookie = 'product_frame=' + window.location.href;
}

function loadLeftMenu() {
	var cookieName = "left_frame";
	var value = GetCookie(cookieName);
	if (value == null ) {
	
	}
	else {
		window.location.href = value;
	}
}

function loadProductPage() {
	var cookieName = "product_frame";
	var value = GetCookie(cookieName);
	if (value == null ) {
	
	}
	else {
		window.location.href = value;
	}
}

function SetCookie (name,value,expires,path,domain,secure)
  {
          document.cookie = name + "=" + escape (value) +
          ((expires) ? "; expires=" + expires.toGMTString() : "") +
          ((path) ? "; path=" + path : "") +
          ((domain) ? "; domain=" + domain : "") +
          ((secure) ? "; secure" : "");
  }

function getCookieVal (offset)
  {
          var endstr = document.cookie.indexOf (";", offset);
          if (endstr == -1)
                  endstr = document.cookie.length;
          return unescape(document.cookie.substring(offset, endstr));
  }

function GetCookie (name)
  {
          var arg = name + "=";
          var alen = arg.length;
          var clen = document.cookie.length;
          if( (document.cookie == null) || (document.cookie.length == null))
          {
                  return null;
          }
          var i = 0;
          while (i < clen)
          {
                  var j = i + alen;
                  if (document.cookie.substring(i, j) == arg)
                          return getCookieVal (j);
                  i = document.cookie.indexOf(" ", i) + 1;
                  if (i == 0) break;
          }
         return null;
  }

function mover(img_name,img_src) { 
document[img_name].src=img_src; } 

function mdown(img_name,img_src) { 
document[img_name].src=img_src; } 

function mout(img_name,img_src) { 
document[img_name].src=img_src; }

function display_alert(field, string) { 
	if( field.value == 0 ) {
		alert(string);
	}
}

function display_alert_multi(arrayin, form, string) { 
	for (var i = 0; i < arrayin.length; i++) {
      		if (arrayin[i].checked == 1) {
         		var select = form.elements[arrayin[i].value];
			if(select.options[select.selectedIndex].value == "0") {
				alert(string);
			}
      		}
	}
}

function check_integer(field) { 
	var intValue = parseInt(field.value);

	if (isNaN(intValue)) {
   		field.value = "1";
	} else if (intValue == 0) {
   		field.value = "1";
	} else {
   		field.value = intValue;
	}
}

function check_float(field) { 
	var floatValue = parseFloat(field.value);

	if (isNaN(floatValue)) {
   		field.value = "1";
	} else {
   		field.value = floatValue;
	}
}

function calendarUpt(form, dayStr) {
	var select = form.elements['month'];
	var month = select.options[select.selectedIndex].value;
	var selecty = form.elements['year'];
	var year = selecty.options[selecty.selectedIndex].value;
	var index = form.day.selectedIndex;

	if(month == "0") {
		//nathing
	}
	if(month == "01" || month == "03" || month == "05" || month == "07" || month == "08" || month == "10" || month == "12") {
		form.day.length = daysofmonths[2].length;
		form.day.options[0].text = dayStr;
		form.day.options[0].value = 0;
		for(i=1;i<daysofmonths[2].length;i++) {
			form.day.options[i].text = daysofmonths[2][i-1];
			form.day.options[i].value = daysofmonths[2][i-1];
		}
	}
	if( month == "04" || month == "06" || month == "09" || month == "11") {
		form.day.length = daysofmonths[1].length;
		form.day.options[0].text = dayStr;
		form.day.options[0].value = 0;
		for(i=1;i<daysofmonths[1].length;i++) {
			form.day.options[i].text = daysofmonths[1][i-1];
			form.day.options[i].value = daysofmonths[1][i-1];
		}
	}
	if(month == "02") {
		if((year % 4) == 0) {
			form.day.length = daysofmonths[3].length;
			form.day.options[0].text = dayStr;
			form.day.options[0].value = 0;
			for(i=1;i<daysofmonths[3].length;i++) {
				form.day.options[i].text = daysofmonths[3][i-1];
				form.day.options[i].value = daysofmonths[3][i-1];
			}
		} else {
			form.day.length = daysofmonths[0].length;
			form.day.options[0].text = dayStr;
			form.day.options[0].value = 0;
			for(i=1;i<daysofmonths[0].length;i++) {
				form.day.options[i].text = daysofmonths[0][i-1];
				form.day.options[i].value = daysofmonths[0][i-1];
			}
		}
	}
}

function OpenPopUp(url)
{
	NewWin = window.open(url ,'', 'width=375,height=480,resizable');
	NewWin.focus();
}

function OpenPopUpParams(url, w, h, xtr)
{
	NewWin = window.open(url ,'', 'width=' + w + ',height=' + h + ',' + xtr);
	NewWin.focus();
}

function set_browser(form) {
    // Define if MS browser used.
    var uAgent=navigator.userAgent.toLowerCase();
    var msbrowser = ((uAgent.indexOf("msie") != -1) && (uAgent.indexOf("opera") == -1));

    // Get the version.    
    var version = parseInt(navigator.appVersion);
    
    // Check if MS IE 4 used.
    var msie4 = (msbrowser && (version == 4) && (uAgent.indexOf("msie 4")!=-1) );

    if ( msie4 ) {
	form.ie4.value=1;
    }
    else {
	form.ie4.value=0;
    }
}

