var CID, FunctionName, InputName, PanelId, TimeToActivate = null
function clickHandler(FunctionName, InputName, PanelId, TimeToActivate){
	clearTimeout(CID)
	CID = setTimeout('getSuggestions(\''+FunctionName+'\', \''+InputName+'\', \''+PanelId+'\')', TimeToActivate);
}

function getSuggestions(FunctionName, InputName, PanelId){		
	var input = escape(document.getElementById(InputName).value);
	ASPAjax.liveASP(FunctionName+'("'+input+'", "'+PanelId+'")', PanelId)
}

function SubmitForm(SubmitName, strValue){
	document.getElementById(SubmitName).value = strValue;
	//document.forms["form1"].submit();
	//document.forms.["SKU1"].focus();
	document.getElementById(SubmitName).focus();
	document.getElementById(SubmitName).click();
}

function SubmitFormDisableLink(ActionId, strValue, DisableId, alertmsg){
	document.getElementById(ActionId).value = strValue;
	document.getElementById(DisableId).href   = "javascript:alert('"+alertmsg+"')";
	document.getElementById("form1").submit();
}

function DeleteLine(strValue){
	document.getElementById("DeleteLine").value = strValue;
	document.getElementById("form1").submit();
}

function SubmitFormOnFocus(SubmitName, strValue){
	document.getElementById("action").value = strValue;
	document.getElementById("form1").submit();
	}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

function SelectDate(id){
var selector = "";
selector = "#DateTime"+id;
	$(document).ready(function(){
		$(selector).datepicker({ dateFormat: 'dd/mm/yy' });
	});
}
	
function startTime(ElementId) {
	var today=new Date();
	var h=today.getHours();
	var m=today.getMinutes();
	var s=today.getSeconds();
	m=PutZero(m);
	s=PutZero(s);
	document.getElementById(ElementId).innerHTML=h+":"+m+":"+s;
	t=setTimeout('startTime(\''+ElementId+'\')',500);
}

function PutZero(i) {
	if (i<10) {
	  i="0" + i; }
	return i;
}


function countDown(min, sec, ElementId) {
  sec--;
  if (sec == -01) {
    sec = 59;
    min = min - 1;
  } else {
   min = min;
  }
	if (sec<=9) { sec = "0" + sec; }
  time = (min<=9 ? "" + min : min) + ":" + sec + "";
	document.getElementById(ElementId).innerHTML=time;
  t=setTimeout('countDown(\''+min+'\', \''+sec+'\', \''+ElementId+'\');', 1000);
	if (min == '0' && sec == '00') { sec = "00"; alert('Submit'); }
}

function numdecimalsonly(obj, str, lcid){
	var strValidChars = "1234567890";
	if (lcid == 1030) { strValidChars = strValidChars+"," }
	else { strValidChars = strValidChars+"." }
	for(i = 0; i < str.length; i++){
	if (strValidChars.indexOf(str.charAt(i)) < 0)
		obj.value = str.replace(str.charAt(i), "");
  }
}

function numbersonly(obj, str){
	var strValidChars = "1234567890";
	for(i = 0; i < str.length; i++){
	if (strValidChars.indexOf(str.charAt(i)) < 0)
		obj.value = str.replace(str.charAt(i), "");
  }
}

function FixNum(str) {
	if (str == "") {str = 0;}
	else {
	str = str.replace(",", ".");
	str = parseFloat(str); }
	return str;
}

function RevFixNum(str, lcid) {
	if (str == "") {str = 0; str = str.toFixed(2);}
	else {
		str = parseFloat(str);
		str = str.toFixed(2); // only 2 decimals allowed
		//str = Math.round(str*100)/100;
	}
	if (lcid == 1030) { 
	  str = str+''; // convert to string and replace
		str = str.replace(".", ","); 
		return str; }
	else { return str; 	}
}


var win= null;
function NewWin(mypage,w,h,myname){
	var winl = (screen.width-w)/2;
	var wint = ((screen.height-h)/3);
	//var winl = (document.body.offsetWidth)/2;
	//var wint = (document.body.offsetHeight)/2;
	
	settings='height='+ h +',width=' +w+ ',top=' +wint+ ',left='+ winl+ ',scrollbars=no,toolbar=no'
	win=window.open(mypage,myname,settings)
	if(parseInt(navigator.appVersion) >= 4){win.window.focus();}
}
// end script here -->
// <a href="#" onclick="NewWin('http://akator.net/','710','548','Loading');" > Popup </a>


