
var buffer='';
	
function CheckApostrophy(fieldname)
{
	if (fieldname.value.indexOf("'")!=-1)
	{
		alert('Template cannot contain apostrophy ');
		fieldname.value=fieldname.value.replace("'","");
		return true;
	} 
	return false;
}

function preloadImages()
{
	var d=document;
	if(d.images)
		{
		if(!d.arr) d.arr=new Array();
		var i;
		var j=d.arr.length,a=preloadImages.arguments;
		for(i=0;i<a.length;i++)
			if (a[i].indexOf("#")!=0)
				{
				d.arr[j]=new Image;
				d.arr[j++].src=a[i];
				}
		}
}

function SwitchCheckbox(checkbox,from,to)
{
//select to turn all ON or all OFF
var temp = document.getElementById(checkbox + from );
var turnto=new Boolean(false);
if (temp.checked==true)
	turnto=false;
else
	turnto=true;

for (x = parseInt(from); x <= parseInt(to); x++)
    {
    var temp = document.getElementById(checkbox + x);
    temp.checked=turnto;
    } 
}

function RadioValue(radioButton)
{
    for (x = 0; x <= radioButton.length; x++)
    {
        if (radioButton[x].checked == true) return radioButton[x].value; 
    } 
         // if it didn't find anything, return the .value  (behaviour of single radio btn)
        return radioButton.value;
}

function switchImage(oldimage,newimage)
{
	oldimage.src=newimage
}

 function switchPlus(control,i)
 {
 var objRegExp = /plus/;
 if (objRegExp.test(control.src))
	{switchImage(control,"img/minus.gif");showDiv("div_" + i);}
else
	{switchImage(control,"img/plus.gif");hideDiv("div_" + i);}
 }
 
 
function Select_ShowHide2(control,right_name,main_name)
{
if (control=='main')
{
	hideDiv('main_' + main_name);
	showDiv('right_' + right_name);
	Form1.templates.value= Form1.templates.value.replace('|' + main_name + '$','' )
}
else
 {	hideDiv('right_' + right_name);
	showDiv('main_' + main_name);
	Form1.templates.value= Form1.templates.value + '|' + main_name + '$'
 }
}
 
function Select_ShowHide(control,name)
{
if (control=='main')
{
	hideDiv('main_' + name);
	showDiv('right_' + name);
	Form1.templates.value= Form1.templates.value.replace('|' + name + '$','' )
}
else
 {	hideDiv('right_' + name);
	showDiv('main_' + name);
	Form1.templates.value= Form1.templates.value + '|' + name + '$'
 }
}
 
 function switchDiv(mydiv,my_img)
 {
	var temp;
	
	temp = document.getElementById(mydiv);
	if (temp.style.display == 'block')	
  		{
  		temp.style.display = 'none';
  		my_img.src='img/min_max.jpg';}
	else
		{
		
		temp.style.display = 'block';
		my_img.src='img/minus.jpg';}
 }
 
  function switchDiv2(mydiv,my_img)
 {
	var temp;
	
	temp = $(mydiv);
	
	if (temp.style.display == 'block' || temp.style.display == '')	
  		{temp.style.display = 'none';
  		my_img.src='img/plus.gif';}
	else
		{temp.style.display = 'block';
		my_img.src='img/minus.gif';}
 }
 
 function switchDiv(mydiv)
 {
	var temp;
	
	temp = document.getElementById(mydiv);
	if (temp.style.display == 'block')	
  		{
  		temp.style.display = 'none';
  		}
	else
		{
		temp.style.display = 'block';
		}
 }
 function Show_Sub(mydiv)
 {

	var temp;	
	temp = document.getElementById('sub_' + mydiv);
	if (temp.style.display == 'block')	
  		temp.style.display = 'none';
	else
		temp.style.display = 'block';
		return false;

 }
 
 function Show_AppHarSer(div_app,div_har,div_ser)
 {
 showDiv(div_ser);
 showDiv(div_har);
 showDiv(div_app);
 }
 
function showDiv(mydiv)
 {
	var temp;
	temp = document.getElementById(mydiv);
  	temp.style.display = 'block';

 }

function CheckLogoWildChar(AddingText, Value)
{
	var MyStr = Value;
	if ((MyStr.indexOf("~") > -1)
	 			|| (MyStr.indexOf("|") > -1)
	 			|| (MyStr.indexOf('"') > -1))
	 			/*|| (MyStr.indexOf("\'") > -1))*/
	{
			strMsg=AddingText + " should not contain below Characters." + "\n(Double Quote And Pipe)";
			alert(strMsg);
		return false;
	}
}
 		
function hideDiv(mydiv)
 {
	var temp;
	temp = document.getElementById(mydiv);
  	temp.style.display = 'none';

 }


//Declaring valid date character, minimum year and maximum year
var dtCh= "/";
var minYear=1900;
var maxYear=2100;

function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){   
        //Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    //All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag){
	var i;
    var returnString = "";
    //Search through string's characters one by one.
    //If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function daysInFebruary (year){
	//February has 29 days in any year evenly divisible by four,
    //EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this
}

function makeArray(IntarrSize) {

  for (var n = 0; n < IntarrSize; n++)
    this[n] = "";

  return this;

}

function customSplit(strvalue, separator, arrayName) {
  var n = 0;

  if (separator.length != 0) {
    while (strvalue.indexOf(separator) != -1) {
      eval("arr"+n+" = strvalue.substring(0, strvalue.indexOf(separator));");
      strvalue = strvalue.substring(strvalue.indexOf(separator)+separator.length,
          strvalue.length+1);
      n++;
    }
    eval("arr" + n + " = strvalue;");
    arraySize = n+1;
  }
  else {
    for (var x = 0; x < strvalue.length; x++) {
      eval("arr"+n+" = \"" + strvalue.substring(x, x+1) + "\";");
      n++;
    }
    arraySize = n;
  }

  eval(arrayName + " = new makeArray(arraySize);");

  for (var i = 0; i < arraySize; i++)
    eval(arrayName + "[" + i + "] = arr" + i + ";");

  return arraySize;
}


function isDate(argvalue){
if (argvalue.length==0)
  return true

	var dtStr=argvalue
	var daysInMonth = DaysArray(12)
	var pos1=dtStr.indexOf(dtCh)
	var pos2=dtStr.indexOf(dtCh,pos1+1)
	var strMonth=dtStr.substring(0,pos1)
	var strDay=dtStr.substring(pos1+1,pos2)
	var strYear=dtStr.substring(pos2+1)
	strYr=strYear
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYr)
	if (strYear.length==2)
		{var myyear= '20' + String(strYear);
		strYr= myyear
		strYear=myyear
		 year=parseInt(strYr)
		}
		
	if (pos1==-1 || pos2==-1){
		return false
	}
	if (strMonth.length<1 || month<1 || month>12){
		return false
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		alert("Please enter a valid day")
		return false
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		return false
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		return false
	}
return true
}

function isEmail(argvalue) {
if (argvalue.length==0)
  return true
  if (argvalue.indexOf(" ") != -1)
    return false;
  else if (argvalue.indexOf("@") == -1)
    return false;
  else if (argvalue.indexOf("@") == 0)
    return false;
  else if (argvalue.indexOf("@") == (argvalue.length-1))
    return false;

  //arrayString = argvalue.split("@"); (works only in netscape3 and above.)
  var retSize = customSplit(argvalue, "@", "arrayString");

  if (arrayString[1].indexOf(".") == -1)
    return false;
  else if (arrayString[1].indexOf(".") == 0)
    return false;
  else if (arrayString[1].charAt(arrayString[1].length-1) == ".") {
    return false;
  }
  return true;
}

function isURL(argvalue) {
if (argvalue.length==0)
  return true;
  if (argvalue.indexOf(" ") != -1)
    return false;
  else if (argvalue.indexOf("http:'") == -1)
    return false;
  else if (argvalue == "http:'")
    return false;
  else if (argvalue.indexOf("http:'") > 0)
    return false;

  argvalue = argvalue.substring(7, argvalue.length);
  if (argvalue.indexOf(".") == -1)
    return false;
  else if (argvalue.indexOf(".") == 0)
    return false;
  else if (argvalue.charAt(argvalue.length - 1) == ".")
    return false;

  if (argvalue.indexOf("/") != -1) {
    argvalue = argvalue.substring(0, argvalue.indexOf("/"));
    if (argvalue.charAt(argvalue.length - 1) == ".")
      return false;
  }

  if (argvalue.indexOf(":") != -1) {
    if (argvalue.indexOf(":") == (argvalue.length - 1))
      return false;
    else if (argvalue.charAt(argvalue.indexOf(":") + 1) == ".")
      return false;
    argvalue = argvalue.substring(0, argvalue.indexOf(":"));
    if (argvalue.charAt(argvalue.length - 1) == ".")
      return false;
  }
  return true;
}


function isW(argvalue) {
  var onechar = "";

  for (var n = 0; n < argvalue.length; n++) {
    onechar = argvalue.substring(n, n+1);
    if ((onechar < "0" || onechar > "9") && (onechar < "A" ||
      onechar > "Z") && (onechar < "a" || onechar > "z") &&
         (onechar != "_" && onechar != " " && onechar != "'")) {
      return false;
    }
  }

  return true;

}

function isNumeric(argvalue)
   // check for valid numeric strings	
   {
   var strValidChars = "0123456789.-";
   var strChar;
   var blnResult = true;
   var strString=argvalue

   if (strString.length == 0) return true;

   // 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 isPhone(argvalue){ 

var strPhone= argvalue;
if(strPhone.length != 0){
      if((strPhone.length == 10 || strPhone.length==7) && isNumeric(argvalue))
      return true;

      if((strPhone.length == 11 || strPhone.length == 12) && isNumeric_Space_Dash(argvalue))
      return true;

      if(strPhone.substr(0,1) != "(") //Is the First character a ( 
      return false; 

      if(strPhone.substr(4,1) != ")") //Is Forth character a ) 
      return false; 

      if(strPhone.length != 14 && strPhone.length != 13) //Is your phone number the correct length 
      return false; 
					}
return true; //If we got here the number is OK. 
}

function isNumeric_Space_Dash(argvalue) {
  if (argvalue.length != 0)
	for (var n = 0; n < argvalue.length; n++)
      if (argvalue.substring(n, n+1) < "0" || argvalue.substring(n, n+1) > "9")
         if (argvalue.substring(n, n+1) != " " && argvalue.substring(n, n+1) != "-")
            return false;
  return true; 

}


function isTime(argvalue) {
//Checks if time is in HH:MM:SS AM/PM format.
//The Seconds are optional

if(argvalue.length != 0)
{
var timePat = /^(\d{1,2}):(\d{2})(:(\d{2}))?(\s?(AM|am|PM|pm|Pm|pM|Am|aM))?$/;
var timeStr=argvalue
var matchArray = timeStr.match(timePat);
if (matchArray == null) {
	//alert("Time is not in a valid format.");
	return false;
}
hour = matchArray[1];
minute = matchArray[2];
second = matchArray[4];
ampm = matchArray[6];
	
if (second=="") { second = null; }
if (ampm=="") { ampm = null ; return false}

if (hour < 0  || hour > 12) {return false;}
if  (hour > 12 && ampm != null) {return false;}
if (minute<0 || minute > 59) {return false;}
if (second != null && (second < 0 || second > 59)) {return false;}

}
return true;
}


function Max_Length(argvalue,length){ 
	if(argvalue.length > length)
		return false;
	return true;
}

function Min_Length(argvalue,length){ 
	if(argvalue.length < length)
		return false;
	return true;
}

function PopupWindown(Page_Name)
{
	eval("answer= window.open('" + Page_Name + "', 'datagrid', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=600,height=300,left = 30,top = 30');");

}

function popUp(ControlType,Controlvalue,initial_value)
{if (ControlType=='SETUP HEADER/TRAILER')
		eval("answer= window.open('popupRichText.aspx?Type=" + ControlType + "&Value=" + Controlvalue + "', 'datagrid', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=600,height=400,left = 30,top = 30');");
else
   {
   if (ControlType=='UPLOAD IMAGE')
		eval("answer= window.open('popupUpload.aspx?Type=" + ControlType + "&Value=" + Controlvalue + "', 'datagrid', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=900,height=340,left = 30,top = 30');");
   else
		if (ControlType=='UPLOAD DOC')
			eval("answer= window.open('popupDocUpload.aspx?Type=" + ControlType + "&Value=" + Controlvalue + "&Initial_Value=' + initial_value , 'datagrid', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=600,height=300,left = 30,top = 30');");
	else
		{
		var width=600
		var heigth=400
		
		initial_value= initial_value.replace(/\+/g,'CODEPLUS');
		initial_value= initial_value.replace(/\&/g,'CODEAND');
		initial_value= initial_value.replace(/\#/g,'CODEDIEZ');
		initial_value= initial_value.replace(/\\/g,'CODEBAR');
		Controlvalue= Controlvalue.replace(/\+/g,'CODEPLUS');
		Controlvalue= Controlvalue.replace(/\\/g,'CODEBAR');
		Controlvalue= Controlvalue.replace(/\&/g,'CODEAND');
		Controlvalue= Controlvalue.replace(/\#/g,'CODEDIEZ');
		
		if (ControlType=="CALENDAR")
		{
		width=200;
		heigth=220;
		}		
		eval("answer= window.open('popup.aspx?Type=" + ControlType + "&Value=" + Controlvalue + "&Initial_Value=' + initial_value , 'datagrid', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=" + width + ",height=" + heigth + ",left = 30,top = 30');");
		}
	}
}

function ClearOptions(OptionList) {
   //Always clear an option list from the last entry to the first
   for (x = OptionList.length; x >= 0; x--) {
      OptionList[x] = null;
   }
}


function AddToOptionList(OptionList, OptionValue, OptionText) {
   //Add option to the bottom of the list
   OptionList[OptionList.length] = new Option(OptionText, OptionValue);
}


var NS4 = (navigator.appName == "Netscape" && parseInt(navigator.appVersion) < 5);

function addOption(theSel, theText, theValue)
{
	var newOpt = new Option(theText, theValue);
	var selLength = theSel.length;
	theSel.options[selLength] = newOpt;
}

function deleteOption(theSel, theIndex)
{	
	var selLength = theSel.length;
	if(selLength>0)
	{
		theSel.options[theIndex] = null;
	}
}

function moveOptions(theSelFrom, theSelTo)
{
	var selLength = theSelFrom.length;
	var selectedText = new Array();
	var selectedValues = new Array();
	var selectedCount = 0;
	
	var i;
	
	//Find the selected Options in reverse order
	//and delete them from the 'from//Select.
	for(i=selLength-1; i>=0; i--)
	{
		if(theSelFrom.options[i].selected)
		{
			selectedText[selectedCount] = theSelFrom.options[i].text;
			selectedValues[selectedCount] = theSelFrom.options[i].value;
			deleteOption(theSelFrom, i);
			selectedCount++;
		}
	}
	
	//Add the selected text/values in reverse order.
	//This will add the Options to the 'to//Select
	//in the same order as they were in the 'from' Select.
	for(i=selectedCount-1; i>=0; i--)
	{
		addOption(theSelTo, selectedText[i], selectedValues[i]);
	}
	
	if(NS4) history.go(0);
}

function select_all(m1)
{
	for (i=0; i<m1.length; i++) 
		m1.options[i].selected = true; 
}


function submit_form(myform)
{
	myform.submit();
}


function pausecomp(millis) 
{
var date = new Date();
var curDate = null;

do { curDate = new Date(); } 
while(curDate-date < millis);
} 


function GetQueryString()
 {
	var qsParm = new Array();
	var query = window.location.search.substring(1);
	var parms = query.split('&');
	for (var i=0; i<parms.length; i++)
	 {
		var pos = parms[i].indexOf('=');
		if (pos > 0)
		 {
			var key = parms[i].substring(0,pos);
			var val = parms[i].substring(pos+1);
			qsParm[key] = val;
		}
	}
	return qsParm;	
}


function makeLayer(id,L,T,W,H,bgColor,visible,zIndex,content,bbb) {
 if (document.layers) {
  if (document.layers[id]) {
   alert ('Layer with this ID already exists!')
   return
  }
  var LR=document.layers[id]=new Layer(W)
  LR.name= id
  LR.left= L
  LR.top = T
  LR.clip.height=H
  LR.visibility=(null==visible || 1==visible ? 'show' : 'hide')
  if(null!=zIndex)  LR.zIndex=zIndex
  if(null!=bgColor) LR.bgColor=bgColor
 }
 else if (document.all) {
  if (document.all[id]) {
   alert ('Layer with this ID already exists!')
   return
  }
  var LR= '\n<DIV class=drag id='+id+' style="position:absolute'
  +'; left:'+ L
  +'; top:'+ T
  +'; width:'+W
  +'; height:'+H
  +'; clip:rect(0,'+W+','+H+',0)'
  +'; visibility:'+(null==visible || 1==visible ? 'visible':'hidden')
  +(null==zIndex  ? '' : '; z-index:'+zIndex)
  +(null==bgColor ? '' : '; background-color:'+bgColor)
  +'">'
  + content + '</DIV>'
  document.body.insertAdjacentHTML("BeforeEnd",LR)
 }
}


function createsimplediv(id,W,H,PosX,PosY,zIndex,content,isround,isIFRAME)
{
var newdiv=true;
if (document.all) {
  if (document.all[id]) {
   var temp=$(id);
   if (temp!=null)
   	{
		temp.style.display='block';
		newdiv=false;
		temp.innerHTML='';
   	//temp.innerHTML=content;
	}  
  }
  
  var hastail='no';
  if (isround==null)
  	isround='';
	if (isIFRAME==null)
		isIFRAME=0;
	
  if (isround!='')
  	{
		
		//CONSIDER THE IFRAME
		H = H + 93 ;
		classtype='';
		var varY=parseInt(PosY);
		var varFlag = false;
		if(parseInt(parseInt(window.screen.width)-parseInt(window.screen.width)/4 )<= parseInt(parseInt(window.event.x)+parseInt(W)-parseInt(W)/10) )
		{
			
			PosX = parseInt(window.event.x) - parseInt(W); 
			varFlag = true;
			
		}
		else
		{
			PosX = window.event.x;
			hastail = '';			
			
		}
		if(parseInt(window.screen.height) - parseInt(window.screen.height) / 4<= parseInt(PosY)+parseInt(H) )
		{
			PosY = parseInt(PosY) - (parseInt(H)*6/7);
			PosX = parseInt(PosX) - parseInt(W)/3; 
			var varFrameX=parseInt(window.event.x)-parseInt(PosX);
			
			if((parseInt(window.screen.width)- parseInt(varFrameX)- parseInt(W)/2 ) >= parseInt(PosX))
			{
				
 				if(varFlag)
				{
					PosY = parseInt(PosY) + (parseInt(H)/2);
					PosX = parseInt(PosX) + parseInt(W)/2;
				}
		}
			else
			{		
				PosY = parseInt(PosY) - (parseInt(H)/2);
			}
		}
		else
		{
			if(varFlag == false)
			{
				PosY = varY;
				PosY = parseInt(PosY) - (parseInt(H)*6/7);
				PosX = parseInt(PosX) - parseInt(W)/3; 
			}
		}
	}
  else
  	classtype='class=moveme ';

//PosY = parseInt(PosY) - 10;
PosX = parseInt(PosX) - 15; 

classtype='class=handle handlefor="' + id + '"';
  var FullLR= '\n<DIV id='+id+' style="position:absolute'
  +'; left:'+ PosX
  +'; top:'+ PosY
  +'; width:'+W
  +'; height:'+H
  +'; clip:rect(0,'+W+','+H+',0)'
  +';background: none '	  
  +(null==zIndex  ? '' : '; z-index:'+zIndex)
  +'">';
var LR  ='';
  if (isround!='')
  		{
		  LR= LR + '<table width=100% cellpadding=0 cellspacing=0><tr><td width=15>' 
  	 		     +	'<img src="img/roundedcorner/tl.gif" alt="" '
		         +	' width="15" height="15" class="corner" '
				 + 'style="display: block"/></td><td class="roundcont"><img class=drag onClick=\'$("' + id + '").style.display="none";\' src="img/closebutton.jpg"></td> '
			     + ' <td class="roundtop"  width="15"></td></tr>'
			     + '<tr><td colspan=3 class="roundcont" style="padding:10px">';
		}
		
    //LR= LR + '<div id="' + id + 'sub"  ' + classtype + '><small><small><u>Move me</u></small></div>' + content ;
    LR= LR + content;
    if (isround!='')
  		{
		  LR= LR + '</td></tr><tr><td width=15>' ;
		  LR= LR + '	 <img src="img/roundedcorner/bl.gif" alt="" ';
		  LR= LR + '	 width="15" height="15" class="corner" ';
		  LR= LR + '	 style="display: block" />'	  ;
		  LR= LR + '</td><td class="roundcont"></td><td width="15" class="roundbottom">';
		  LR= LR + '</td></tr>';
		  if (hastail!='no')
		  	LR= LR + '<tr><td colspan=3 align=center><img src="img/roundedcorner/tail.gif"></td></tr>';
		 LR= LR + ' </table>' ;
		}

  FullLR= FullLR + LR + '</DIV>';
if (newdiv)
  document.body.insertAdjacentHTML("BeforeEnd",FullLR)
else
{
 temp.innerHTML=LR;
 temp.style.top=PosY;
 temp.style.left=PosX;
 
 
}
 }	
	
}

//Define a function to hide layers
function hideSlide(name) {
  refSlide(name).visibility = hideName;
  }

//Define a function to reveal layers
function showSlide(name,x,y) {
  refSlide(name).visibility = showName;
  //document.all.Banner.moveTo(300,300);
   //x.style.clip.top
  //refSlide(name).moveToAbsolute(x,y);
  
  }

//Define a central function to reference layers
function refSlide(name) {
  if (NN) { return document.layers[name]; }
  else { return eval('document.all.' + name + '.style'); }
  }


function makeLayer(id,W,H,blackW,blackH,L,T,bgColor,visible,zIndex,content) {
 
 if (document.all) {
   if (document.all[id]) {
   alert ('Layer with this ID already exists!')
   return
  }
//  if (!e) var e = window.event;
//second window, black
   var LR2= '\n<DIV id=div_'+id+'s style="position:absolute'
  +'; left:'+ '0'
  +'; top:'+ '0'
  +'; width:'+ blackW
  +'; height:'+ blackH
  +'; clip:rect(0,' + blackW + ',' + blackH + ',0)'
  +'; visibility:'+ (null==visible || 1==visible ? 'visible':'hidden')
  +(null==zIndex  ? '' : '; z-index:'+ zIndex)
  +(null==bgColor ? '' : '; background-color:#333333;')
  + ' filter:alpha(opacity=80); '
  +'" '
  + ' onScroll=alert("hello");'
  + '></DIV>'
  document.body.insertAdjacentHTML("BeforeEnd",LR2)
 
  
  var LR= '\n<DIV class=moveme  id=div_'+id+' style="position:absolute'
  +'; left:'+ L
  +'; top:'+ T
  +'; width:'+ W
  +'; height:'+ H
  +'; clip:rect(0,'+ W +','+ H +',0)'
  +'; visibility:'+(null==visible || 1==visible ? 'visible':'hidden')
  +(null==zIndex  ? '' : '; z-index:'+zIndex)
  +'">' 
  + content  +  '</DIV>';
  //+ '<table class=weblistTable><tr><td align=right><a href=# onClick=\"deleteLayer(\'div_s1\');deleteLayer(\'div_s1s\');return false; \">Close</td></tr></table>'
  
   
  
  //+(null==bgColor ? '' : '; background-color:'+bgColor)
  
  document.body.insertAdjacentHTML("BeforeEnd",LR)
 }
}

function deleteLayer(id) {
 if (document.layers && document.layers[id]) {
  document.layers[id].visibility='hide'
  delete document.layers[id]
 }
 if (document.all && document.all[id]) {
  document.all[id].innerHTML=''
  document.all[id].outerHTML=''
 }
}

function ScrollLayers()
{

		var x =  document.getElementById('div_s1');
		if (x !=null){
		       setTimeout("moveit('div_s1',10)",85);		
					 }
}

function moveit(divname,speed)
{

		var x =  document.getElementById(divname);
		if (x !=null)
		{
		
	//	if (x.style.pixelTop > document.body.scrollTop + 200)
			x.style.top= document.body.scrollTop + 200;
	//	if (x.style.pixelTop < document.body.scrollTop + 200)
	//		x.style.top= document.body.scrollTop + 200;	
		}
}





function DesignLayer(id,W,H,L,T,bgColor,visible,zIndex,content) {
 
	if (document.all) {
		if (document.all[id])
		 {
			alert ('Layer with this ID already exists!')
			return
		 }
	  
	var LR= '\n<DIV id=div_'+id+' style="position:absolute'
	+'; left:'+ L
	+'; top:'+ T
	+'; width:'+ W
	+'; height:'+ H
	+'; clip:rect(0,'+ W +','+ H +',0)'
	+'; visibility:'+(null==visible || 1==visible ? 'visible':'hidden')
	+(null==zIndex  ? '' : '; z-index:'+zIndex)
	+(null==bgColor ? '' : '; background-color:'+bgColor)
	+'">' 
	+ content
	+ '</DIV>'
	  

	document.body.insertAdjacentHTML("BeforeEnd",LR)
 }
}

function CreateAutomaticLayer(id,W,H,bgColor,visible,zIndex,content) {
 
 if (document.all) {
   if (document.all[id]) {
   alert ('Layer with this ID already exists!')
   return
  }
  
 
  var LR= '\n<DIV id='+ id +' style="position:absolute'
  +'; left:'+ (event.clientX + document.body.scrollLeft + 25)
  +'; top:'+ (event.clientY + document.body.scrollTop -5)
  +'; width:'+ W
  +'; height:'+ H //+'; background:transparent '   +'; opacity: 1.8 '   +'; filter:alpha(opacity=80) '
    +'; clip:rect(0,'+ W +','+ H +',0)'
  +'; visibility:'+(null==visible || 1==visible ? 'visible':'hidden')
  +(null==zIndex  ? '' : '; z-index:'+zIndex)
  +(null==bgColor ? '' : '; background-color:'+ bgColor)
  +'">' 
  + content
  + '<br><div height=100% align=right valign=bottom><a href=# onClick="deleteLayer(\'' + id + '\');return false;"><small>Close</small></div>'
  + '</DIV>'
  
  document.body.insertAdjacentHTML("BeforeEnd",LR)
 }
}


function lite(obj) {
if(document.all&&!window.opera) {
obj.filters.blendTrans.apply(); 
obj.filters.blendTrans.play(); 
} 
} 

function toggleCellsUsed(el)
{
	for (i = 0; i < el.parentNode.parentNode.childNodes.length; i++)
		if (el.parentNode.parentNode.childNodes[i].childNodes[0].className !='WebMultiMerchNotUsed')
			el.parentNode.parentNode.childNodes[i].childNodes[0].className ='WebMultiMerchNotselected';
			
		el.className='WebMultiMerchselected';
}

function ClearCellsUsed(el)
{
	for (i = 0; i < el.parentNode.childNodes.length; i++)
		//if (el.parentNode.childNodes[i].childNodes[0].className !='WebMultiMerchNotUsed')
			el.parentNode.childNodes[i].className ='BlankArrow';
		
		el.className='GreenArrow';

}

function opacity(id, opacStart, opacEnd, millisec) { 
    //speed for each frame 
    var speed = Math.round(millisec / 100); 
    var timer = 0; 

    //determine the direction for the blending, if start and end are the same nothing happens 
    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++; 
        } 
    } 
} 

//change the opacity for different browsers 
function changeOpac(opacity, id) { 
    var xobject = document.getElementById(id); 
	if (xobject==null)
	{	 xobject = parent.document.getElementById(id)
		 if (xobject==null)
		 	{
				alert(id);
				object = document.all[id].style;
				return;
		 	//deleteLayer(id);
			}
		else
		 	object = parent.document.getElementById(id).style; 
	}
	else
		 object = document.getElementById(id).style; 

    object.opacity = (opacity / 100); 
    object.MozOpacity = (opacity / 100); 
    object.KhtmlOpacity = (opacity / 100); 
    object.filter = "alpha(opacity=" + opacity + ")"; 
} 



function displaymessage(message)
{
if (message==null)
	return;
	var mymessage="<table border=0 width=100% height=100% class=webform bordercolor=#000033><tr><td><table width=100% height=100% bgcolor=#FFFFCC><tr><td><b><br><center>" + message + "<br><br></td></tr></table></table></div>";	
	var PosX=document.body.scrollLeft + 225;
    var PosY=document.body.scrollTop + 200;
    createsimplediv('xboxmessage',275,100,PosX,PosY,100,mymessage);

	opacity('xboxmessage', 100, 0, 3000);	
	
}

function createfadingmessage(message,ThisObject,thisTop,thisLeft,side,width,height)
{
	
	if (width==null)
		width='300';
	if (height==null)		
		height='250';
	if (width=='')
		width='300';
	if (height=='')		
		height='250';
		
		
 if (message==null)
	return;

if (ThisObject!=null)	
  {
	  if($(ThisObject)!=null)
		   {
				var XY=	new Array();
				XY=findPos($(ThisObject));
				var x=XY[0];
				var y=XY[1];
								
				if (side!=null)
					{
						x=x;
					}
				thisLeft=x;
				thisTop=y;
		   }
	  else
 	return;
  }
 else
 	return;
	
 var mymessage="<table width=100% height=100%><tr><td width=100%>";
 mymessage =  mymessage + "<div style='height:" + (height/2) + "px;width=100%;overflow:auto;'>" + message + "</div></td></tr></table>";	

    createsimplediv('xboxmessage',width,height,thisLeft,thisTop,100,mymessage,'roundedborders',200);
    opacity('xboxmessage', 0, 100, 1000);	
//	Nifty("div#xboxmessage","big");
	
	
}


function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}


function $() {
  var elements = new Array();
  for (var i = 0; i < arguments.length; i++) {
    var element = arguments[i];
    if (typeof element == 'string')
      element = document.getElementById(element);
    if (arguments.length == 1)
      return element;
    elements.push(element);
  }
  return elements;
}



var timerlen = 5;
var slideAniLen = 350;

var timerID = new Array();
var startTime = new Array();
var obj = new Array();
var endHeight = new Array();
var moving = new Array();
var dir = new Array();


function Animate(objname,my_img)
{
	
	if (my_img.src.match('minus.gif'))
		my_img.src='img/plus.gif';
	else
		my_img.src='img/minus.gif';
	
    document.getElementById(objname).style.overflow="hidden";
    if(document.getElementById(objname).style.display == "none")
      if(document.getElementById("txt" + objname).value !=0)
           {
             slidedown(objname);
	            }
        else
           document.getElementById(objname).style.display = "block";
    else    
        {
          slideup(objname);
         }
}

function slidedown(objname){
        if(moving[objname])
                return;

        if(document.getElementById(objname).style.display != "none")
                return; //cannot slide down something that is already visible

        moving[objname] = true;
        dir[objname] = "down";
        startslide(objname);
}

function slideup(objname){
        if(moving[objname])
                return;

        if(document.getElementById(objname).style.display == "none")
			{
                return; //cannot slide up something that is already hidden
                
            }   
        
        moving[objname] = true;
        dir[objname] = "up";
        startslide(objname);
}

function startslide(objname){
        obj[objname] = document.getElementById(objname);
        
       
         //alert(parseInt(obj[objname].offsetHeight));
        startTime[objname] = (new Date()).getTime();
        //alert(endHeight[objname]);
        if(dir[objname] == "down")
                obj[objname].style.pixelHeight =  1 //"1px";                
        else
                $("Txt" + obj[objname].id).value = parseInt(obj[objname].offsetHeight); //endHeight[objname];  

        //alert(parseInt(obj[objname].offsetHeight));
        endHeight[objname] = $("Txt" + obj[objname].id).value;
        obj[objname].style.display = "block";
        

        timerID[objname] = setInterval('slidetick(\'' + objname + '\');',timerlen);
}

function slidetick(objname){
        var elapsed = (new Date()).getTime() - startTime[objname];
        //alert(elapsed);
        if (elapsed > slideAniLen)
                endSlide(objname)
        else {
                var d =Math.round(elapsed / slideAniLen * endHeight[objname]);
                //alert (endHeight[objname]);
                if(dir[objname] == "up")
                        d = endHeight[objname] - d;
                
                obj[objname].style.pixelHeight = d; //+ "px";
        }

        return;
}

function endSlide(objname){
        clearInterval(timerID[objname]);

        if(dir[objname] == "up")
                obj[objname].style.display = "none";

        obj[objname].style.pixelHeight = endHeight[objname]; // + "px";
        
        delete(moving[objname]);
        delete(timerID[objname]);
        delete(startTime[objname]);
        delete(endHeight[objname]);
        delete(obj[objname]);
        delete(dir[objname]);

        return;
}  

function getPrint(print_area)
		{	
			//Creating new page
			var pp = window.open();
			//Adding HTML opening tag with <HEAD> … </HEAD> portion 
			pp.document.writeln('<HTML><HEAD><title>Print Preview</title><LINK href=Styles.css  type="text/css" rel="stylesheet">')
			pp.document.writeln('<LINK href=style.css  type="text/css" rel="stylesheet" media="print"><base target="_self"></HEAD>')
			//Adding Body Tag
			pp.document.writeln('<body MS_POSITIONING="GridLayout" bottomMargin="0" leftMargin="0" topMargin="0" rightMargin="0">');
			//Adding form Tag
			pp.document.writeln('<form  method="post">');
			//Creating two buttons Print and Close within a table
			pp.document.writeln('<TABLE width=100%><TR><TD></TD></TR><TR><TD align=right><INPUT ID="PRINT" type="button" value="Print" onclick="javascript:location.reload(true);window.print();"><INPUT ID="CLOSE" type="button" value="Close" onclick="window.close();"></TD></TR><TR><TD></TD></TR></TABLE>');
			//Writing print area of the calling page
			if ($(print_area) !=null)
				pp.document.writeln($(print_area).innerHTML);
			else
				pp.document.writeln(print_area + ' div not found');
			//Ending Tag of </form>, </body> and </HTML>
			pp.document.writeln('</form></body></HTML>');			
			
		}		

function createdialogdiv(id,dh,th,content)
{
//alert (id + '  '+ dh + '  ' + th + '  ' + content);
var temp=$(id);
//alert (temp);
if (temp==null)
{
  var FullLR= '\n<DIV id='+id+' style="position:absolute;visibility:hidden;'+'top:0px'+'">';
      FullLR = FullLR + '\n<DIV class="x-dlg-hd">'+ dh + '</div>';
      FullLR = FullLR + '\n<DIV class="x-dlg-bd">'
                              + '\n<DIV class="x-dlg-tab" title="'+ th +'">' 
                                        + '\n<DIV class="inner-tab">'+ content +'</Div>' 
                              + '</Div>'   
                        + '</div>'
                +'</Div>';  

  document.body.insertAdjacentHTML("BeforeEnd",FullLR);
}
else
    {

      var FullLR =  '\n<DIV class="x-dlg-hd">'+ dh + '</div>';
      FullLR = FullLR + '\n<DIV class="x-dlg-bd">'
                              + '\n<DIV class="x-dlg-tab" title="'+ th +'">' 
                                        + '\n<DIV class="inner-tab">'+ content +'</Div>' 
                              + '</Div>'   
                        + '</div>';
 temp.innerHTML= FullLR;

 
}

	
}		



function createTabDiv(TotalTabs,TabHeading,TabContentDiv)
{
id = "TabPanel-1";
var i=1;
var temp=$(id);
//alert (temp);
//alert (id + '  '+ dh + '  ' + th + '  ' + content);
if (temp==null)
{
  var FullLR= '\n<DIV id="'+id+'">';
                        for(i=0;i<TotalTabs;i++)
                        {
                            FullLR = FullLR + '\n<DIV id="Tab'+ TabHeading + i +'" class="tab-content"><pre>'+ $((TabContentDiv) + i).innerHTML + '</pre></div>';                         
                        }
                +'</Div>';  
                

  //alert(FullLR);
  document.body.insertAdjacentHTML("BeforeEnd",FullLR);
}
else
{
  var FullLR =  "";
                        for(i=0;i<TotalTabs;i++)
                        {
                            FullLR = FullLR + '\n<DIV id="Tab'+ TabHeading + i +'" class="tab-content"><pre>'+ $((TabContentDiv) + i).innerHTML + '</pre></div>';                         
                        }
                    +'</Div>';  
                
 temp.innerHTML= FullLR;

}
}

function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}

	

function isValidDate(calendarvalue)
{

if (!isDate(calendarvalue.value))
	{	
	alert(calendarvalue.value + ' is an invalid date');	
	calendarvalue.value='';
	}


}
