//change the text below to reflect your own,
var before=""
var current=""
var montharray=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")

function countdown(yr,m,d)
{
	theyear=yr;themonth=m;theday=d
	var today=new Date()
	var todayy=today.getYear()
	if (todayy < 1000)
		todayy+=1900
	var todaym=today.getMonth()
	var todayd=today.getDate()
	var todayh=today.getHours()
	var todaymin=today.getMinutes()
	var todaysec=today.getSeconds()
	var todaystring=montharray[todaym]+" "+todayd+", "+todayy+" "+todayh+":"+todaymin+":"+todaysec
	futurestring=montharray[m-1]+" "+d+", "+yr

	dd=Date.parse(futurestring)-Date.parse(todaystring)
	
	dday=Math.floor(dd/(60*60*1000*24)*1)
	//alert(dday)
	//var hrs=dday*24;

	dhour=Math.floor((dd%(60*60*1000*24))/(60*60*1000)*1)
	//alert(dhour)
	//dhour=dhour+hrs;
	
	dmin=Math.floor(((dd%(60*60*1000*24))%(60*60*1000))/(60*1000)*1)

	dsec=Math.floor((((dd%(60*60*1000*24))%(60*60*1000))%(60*1000))/1000*1)

	if(dday==0&&dhour==0&&dmin==0&&dsec==1)
	{
		document.getElementById('timer_span').innerHTML=current
		return
	}
	else
		document.getElementById('timer_span').innerHTML='<table cellspacing="0" cellpadding="0" class="timeslot-bg" style="border:1px solid #000000"><tr align=center><td width="40" height="29" class="white">'+dday+'</td><td width="40" height="29" class="white">'+dhour+'</td><td width="40" style="border-left:1px solid #000000;border-right:1px solid #000000" class="white">'+dmin+'</td><td width="40" class="white">'+dsec+'</td></tr></table>';
		setTimeout("countdown(theyear,themonth,theday)",1000)
	}

function add_commas(nStr)
      { 
      nStr += '';
      x = nStr.split('.');
      x1 = x[0];
      x2 = x.length > 1 ? '.' + x[1] : '';
      var rgx = /(\d+)(\d{3})/;
      while (rgx.test(x1)) {
      x1 = x1.replace(rgx, '$1' + ',' + '$2');
      }
      return x1 + x2;
      }


function addOption(selectbox,text,value)
{
var optn = document.createElement("OPTION");
optn.text = text;
optn.value = value;
selectbox.options.add(optn);
}


function ignoreIt()
{
	document.frmData.btnSave.focus();
	return false;
}

function bcheck(fd,msg){
//alert(msg);
if(fd.value=='') {
if(msg!=''){ 
alert(msg);
fd.focus();
}
return true;              
}else{ 
return false;
}

}


function isdomain(dm){

var str=dm.value;	
if(str!=''){
s=str.indexOf('http');

if(s>=0){
alert("Only domain name should be entered as Site Url\nPlease do not put http://");
dm.focus();
return true;
}

}


}


function chkstr(fd,fn){

j=fd.value.length;
        ok = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZäåöšžÀÈÌÒÙàèìòùÁÉÍÓÚÝáéíóúýÂÊÎÔÛâêîôûÃÑÕãñõÄËÏÖÜŸäëïöüÿ-"\'‘ ';
        for(i=0; i<j; i++){
        if (ok.indexOf(fd.value.charAt(i))<0){
               // msg = fn+' can only consist of a-z, A-Z\n';
                alert(fn);
				fd.focus();  
				return true;  
                i=99;
        }
        }

}


function chkalpha(fd,fn){

j=fd.value.length;
        ok = '1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZäåöšžäåöšžÀÈÌÒÙàèìòùÁÉÍÓÚÝáéíóúýÂÊÎÔÛâêîôûÃÑÕãñõÄËÏÖÜŸäëïöüÿ,:;!@#$%^&*().&~\n\r-_$?=/\"\'‘  ';
        for(i=0; i<j; i++){
        if (ok.indexOf(fd.value.charAt(i))<0){
                //msg = fn+' can only consist of alpha numeric characters\n';
                alert(fn);
				fd.focus();  
				return true;  
                i=99;
        }
        }

}


function chknum(fd,fn){

j=fd.value.length;
        ok = '1234567890.-)(+ ';
        for(i=0; i<j; i++){
        if (ok.indexOf(fd.value.charAt(i))<0){
                //msg = fn+' can only consist of numeric characters\n';
                alert(fn);
				fd.focus();  
				return true;  
                i=99;
        }
        }

}

function chkspace(fd,fn){

j=fd.value.length;
        ok = '1234567890,';
        for(i=0; i<j; i++){
        if (ok.indexOf(fd.value.charAt(i))<0){
                //msg = fn+' can only consist of numeric characters\n';
                alert(fn);
				fd.focus();  
				return true;  
                i=99;
        }
        }

}

function removeAllOptions(selectbox)
{
var i;
for(i=selectbox.options.length;i>=0;i--)
{
selectbox.remove(i);
}
}

function DropDownSelect(obj, val)
	{
		var i;
		var len = obj.options.length;
		for (i=0; i<len; i++)
		{
			if (obj.options[i].value == val)
			{
				obj.selectedIndex = i;
				break;
			}
		}
	}


function isEmail (s) {
        //if (isEmpty(s))
    //   if (isEmail.arguments.length == 1) return defaultEmptyOK;
    //   else return (isEmail.arguments[1] == true);
   
    // is s whitespace?
    //if (isWhitespace(s)) return false;
    
    // there must be >= 1 character before @, so we
    // start looking at character position 1
    // (i.e. second character)
    var i;
    var ok;
    var sLength = s.length;
    
//  ok = '1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_@.';
//      for(i=0; i<sLength; i++){
//      if (ok.indexOf(s.value.charAt(i))<0){
//              return false;
//      }
//      }
    i=1;
    // look for @
    while ((i < sLength) && (s.charAt(i) != "@"))
    { i++
    }
    if ((i >= sLength) || (s.charAt(i) != "@")) return false;
    else i += 2;
    // look for .
    while ((i < sLength) && (s.charAt(i) != "."))
    { i++
    }
    // there must be at least one character after the .
    if ((i >= sLength - 1) || (s.charAt(i) != ".")) return false;
    else return true;
}







function GP_AdvOpenWindow(theURL,winName,features,popWidth,popHeight,winAlign,ignorelink,alwaysOnTop,autoCloseTime,borderless) { //v2.0
  var leftPos=0,topPos=0,autoCloseTimeoutHandle, ontopIntervalHandle, w = 480, h = 340;  
  if (popWidth > 0) features += (features.length > 0 ? ',' : '') + 'width=' + popWidth;
  if (popHeight > 0) features += (features.length > 0 ? ',' : '') + 'height=' + popHeight;
  if (winAlign && winAlign != "" && popWidth > 0 && popHeight > 0) {
    if (document.all || document.layers || document.getElementById) {w = screen.availWidth; h = screen.availHeight;}
		if (winAlign.indexOf("center") != -1) {topPos = (h-popHeight)/2;leftPos = (w-popWidth)/2;}
		if (winAlign.indexOf("bottom") != -1) topPos = h-popHeight; if (winAlign.indexOf("right") != -1) leftPos = w-popWidth; 
		if (winAlign.indexOf("left") != -1) leftPos = 0; if (winAlign.indexOf("top") != -1) topPos = 0; 						
    features += (features.length > 0 ? ',' : '') + 'top=' + topPos+',left='+leftPos;}
  if (document.all && borderless && borderless != "" && features.indexOf("fullscreen") != -1) features+=",fullscreen=1";
  if (window["popupWindow"] == null) window["popupWindow"] = new Array();
  var wp = popupWindow.length;
  popupWindow[wp] = window.open(theURL,winName,features);
  if (popupWindow[wp].opener == null) popupWindow[wp].opener = self;  
  if (document.all || document.layers || document.getElementById) {
    if (borderless && borderless != "") {popupWindow[wp].resizeTo(popWidth,popHeight); popupWindow[wp].moveTo(leftPos, topPos);}
    if (alwaysOnTop && alwaysOnTop != "") {
    	ontopIntervalHandle = popupWindow[wp].setInterval("window.focus();", 50);
    	popupWindow[wp].document.body.onload = function() {window.setInterval("window.focus();", 50);}; }
    if (autoCloseTime && autoCloseTime > 0) {
    	popupWindow[wp].document.body.onbeforeunload = function() {
  			if (autoCloseTimeoutHandle) window.clearInterval(autoCloseTimeoutHandle);
    		window.onbeforeunload = null;	}  
   		autoCloseTimeoutHandle = window.setTimeout("popupWindow["+wp+"].close()", autoCloseTime * 1000); }
  	window.onbeforeunload = function() {for (var i=0;i<popupWindow.length;i++) popupWindow[i].close();}; }   
  document.MM_returnValue = (ignorelink && ignorelink != "") ? false : true;
}

function checkEmailValid(emailStr,msg)
{
	var emailPat=/^(.+)@(.+)$/
	var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
	var validChars="\[^\\s" + specialChars + "\]"
	var quotedUser="(\"[^\"]*\")"
	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
	var atom=validChars + '+'
	var word="(" + atom + "|" + quotedUser + ")"
	var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")
	var errMsg="";   
	var matchArray=emailStr.match(emailPat)

	if (matchArray==null) 
	{
	   errMsg=errMsg+"The "+msg+" Email Address seems incorrect!";
	   return errMsg;
	}
	else
	{
	  var user=matchArray[1]
	  var domain=matchArray[2]
	  if (user.match(userPat)==null) 
	  {
		errMsg=errMsg+"The "+msg+" Email Address seems incorrect 111!";
		return errMsg;       
	  }
	  var IPArray=domain.match(ipDomainPat)
	  if (IPArray!=null) 
	  {
		  for (var i=1;i<=4;i++) 
			  {
			if (IPArray[i]>255) 
				{
				errMsg=errMsg+"The "+msg+" Email Address seems incorrect 222!";
				return errMsg;
				}//IF
			  }//for
	   }//IP Array
	   var domainArray=domain.match(domainPat)
	   if (domainArray==null) 
	   {
		 errMsg=errMsg+"The "+msg+" Email Address seems incorrect 333!";
		 return errMsg;
	   }
	   var atomPat=new RegExp(atom,"g")
	   var domArr=domain.match(atomPat)
	   var len=domArr.length
	   if (domArr[domArr.length-1].length<2 || domArr[domArr.length-1].length>6) 
	   {
		 errMsg=errMsg+"The "+msg+" Email Address seems incorrect 444!";
		 return errMsg;	
	   } 
	   if (len<2) 
	   {
		 errMsg=errMsg+"The "+msg+" Email Address seems incorrect 555!";
		 return errMsg;	 
	   } 
	 }//End  Match
	return "0";
}

function goUrl(loc)
	{
	document.location.href=loc;
	}
	
function notYet()
	{
	alert("Sorry this item is not available!")
	}


function WholeNumberOnly(opt,msg)
{
	var pos=opt.value.indexOf(".")
	if  (pos>0)
	  {
		alert("The "+msg+" can only be whole numbers!"); 
		opt.value=opt.value.substr(0,opt.value.length-1);
		opt.focus();
		return false;
	  }	 
	if  (isNaN(opt.value))
	  {
		alert("The "+msg+" can only be whole numbers!"); 
		opt.value=opt.value.substr(0,opt.value.length-1);
		opt.focus();
		return false;
	  }
	  return true;
}

function WholeNumberOnlyEmpty(opt,msg)
{
	var pos=opt.value.indexOf(".")
	if  (pos>0)
	  {
		alert("The "+msg+" can only be whole numbers!"); 
		opt.value="";
		opt.focus();
	  }	 
	if  (isNaN(opt.value))
	  {
		alert("The "+msg+" can only be whole numbers!"); 
		opt.value="";
		opt.focus();
	  }
}

function TinyIntOnly(opt,msg)
{
	if(opt.value>255)
	{
		alert("The "+msg+" can not be greater than 255!");
		opt.value="";
		opt.focus();
	}
}

function NumericOnly(opt,msg)
{
	if  (isNaN(opt.value))
	  {
		alert("The "+msg+" can only be numbers!"); 
		opt.value=opt.value.substr(0,opt.value.length-1);
		opt.focus();
	  }
}

function SetZero(opt)
{
	if  (opt.value=="")
	  {
		opt.value=0;
	  }
}

function SetBlank(opt)
{
	if  (opt.value=="0")
	  {
		opt.value="";
	  }
}


var http_request = false;
   function makePOSTRequest(url, parameters,st) {
      http_request = false;
      if (window.XMLHttpRequest) { // Mozilla, Safari,...
         http_request = new XMLHttpRequest();
         if (http_request.overrideMimeType) {
         	// set type accordingly to anticipated content type
          
            http_request.overrideMimeType('text/html');
         }
      } else if (window.ActiveXObject) { // IE
         try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
         } catch (e) {
            try {
               http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
         }
      }
      if (!http_request) {
         alert('Cannot create XMLHTTP instance');
         return false;
      }
      
      http_request.onreadystatechange = eval('alertContents'+st);
      http_request.open('POST', url, true);
      http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      http_request.setRequestHeader("Content-length", parameters.length);
      http_request.setRequestHeader("Connection", "close");
      http_request.send(parameters);
   }
   
var hh=0,hh2=0;
var inter,inter_val;


function Show_Box(div_id)
{

//Depending on the amount of text, set the maximum height here in pixels
obj = document.getElementById(div_id);

	if(hh2==132)
	{
	clearInterval(inter);
	return;
	}	

	obj.style.visibility = 'visible';
	hh2+=4;
	obj.style.height = hh2 + 'px';
}

//same way as above but reversed
function Hide_Box(div_id)
{
	obj = document.getElementById(div_id);

	if(hh2==4)
	{
	obj.style.visibility = 'hidden';
	obj.style.height = '0.1em';
	clearInterval(inter);
	return;
	}
	hh2-=4;
	obj.style.height = hh2 + 'px';
}



function ShowBox(div_id)
{

//Depending on the amount of text, set the maximum height here in pixels
obj = document.getElementById(div_id);

	if(hh==132)
	{
	clearInterval(inter_val);
	return;
	}	

	obj.style.visibility = 'visible';
	hh+=4;
	obj.style.height = hh + 'px';
}

//same way as above but reversed
function HideBox(div_id)
{
	obj = document.getElementById(div_id);

	if(hh==4)
	{
	obj.style.visibility = 'hidden';
	obj.style.height = '0.1em';
	clearInterval(inter_val);
	return;
	}
	hh-=4;
	obj.style.height = hh + 'px';
}



function show(div_id){
document.getElementById(div_id).style.display='';
}

function hide(div_id){
document.getElementById(div_id).style.display='none';
}

function getParentByTagName(obj, tagName) {
tagName = tagName.toLowerCase();
while (obj!= null && obj.tagName!=null && obj.tagName.toLowerCase() !=
tagName) {
obj=obj.parentNode;
}
return obj;
}

