﻿
var ua = 'msie';
var msg=new String('')
var W=navigator.userAgent.toLowerCase();
if(W.indexOf("opera")!=-1){ua='opera';}else if(W.indexOf("msie")!=-1){ua='msie';} else if(W.indexOf("mozilla")!=-1){ua='gecko';}
if(W.indexOf("opera")!=-1){ua='opera';}else if(W.indexOf("msie")!=-1){ua='msie';} else if(W.indexOf("mozilla")!=-1){ua='gecko';}



function addListener(obj, event, listener){
    if(ua == 'gecko' || ua == 'opera'){
        obj.addEventListener(event, listener, false);
    } else if (ua == 'msie') {
        obj.attachEvent("on"+event,listener);
    }
};

function removeListener(obj, event, listener){
    if(ua == 'gecko' || ua == 'opera'){
        obj.removeEventListener(event, listener, false);
    } else if (ua == 'msie') {
        obj.detachEvent("on"+event,listener);
    }
};




	function check_length(obj,len,lbl)
	{
	 var txt=$(obj).value;
	 
	 if (txt.length>len) 
	 $(obj).value=txt.substring(0,len)
	else
	$(lbl).innerHTML=txt.length 
		
	}
	
function $(id)
{
var item;
if (document.getElementById)
	{
		itm = document.getElementById(id);
	}
	else if (document.all)
	{
		itm = document.all[id];
	}
	else if (document.layers)
	{
		itm = document.layers[id];
	}
	
	return itm;

}

















function Trim(str)
{
   return str.replace(/^\s*|\s*$/g,"");

}

function hs(obj,value,TF)
{
if (! TF)
 $(obj).style.display=value;
else
{
  if ($(obj).style.display=='block')
  $(obj).style.display='none';
else
  $(obj).style.display='block';
}
}


function $ES(txt)
{
 
  return escape(txt)

}

function $css(obj,cn)
{
  $(obj).className=cn;
  
}
 function $FR(obj)
 {
 
   return $(obj).contentWindow;
 
 }
 
 









	function $MC(msg,msgcancel)
{
 if (confirm(msg))
  {
         
         return true;
       }
       else {
          alert (msgcancel);
          return false;
       } 
  
}

function whichButton(event)
{

 return event.keyCode;
}




















function amf_Boolean(v)
{
v=new String(v)
if (v=='true')
return 1;
else
return 0;
}


function go_to(url)
{

document.location.href=url;

}


/*Confirm Delete*/
function deletedata(url)
{
if ($MC('Are You Sure to Delete this?','The Operation is cancled'))
{

go_to(url)

}

}



 






function ckbox(TF,nameck) {
var ck=document.body.getElementsByTagName("input")
for(var i=0;i<ck.length;i++)
{
  if (ck[i].type=='checkbox' && ck[i].name.match(nameck)==nameck)
  ck[i].checked=TF;

}


	}  
	
	

	
	
	function sitemessage()
{
	    var arrayPageSize = getPageSize();
	    var arrayPageScroll = getPageScroll();
	    $('ipd-msg-wrapper').style.position='absolute'
	    $('ipd-msg-wrapper').style.top = (arrayPageScroll[1] + ((arrayPageSize[3] - 35 - 45) / 2) + 'px');
	    $('ipd-msg-wrapper').style.left = (((arrayPageSize[0] - 20 - 220) / 2) + 'px');
	    $('ipd-msg-wrapper').style.display = 'block';
	    $('ipd-msg-text').innerHTML=msg
	    $('ipd-msg-wrapper').style.zIndex = '200'
	    window.setTimeout("hs('ipd-msg-wrapper','none')",2000)
	    
	    
}


function Message(msg)
{
	    var arrayPageSize = getPageSize();
	    var arrayPageScroll = getPageScroll();
	    $('ipd-msg-wrapper').style.position='absolute'
	    $('ipd-msg-wrapper').style.top = (arrayPageScroll[1] + ((arrayPageSize[3] - 35 - 45) / 2) + 'px');
	    $('ipd-msg-wrapper').style.left = (((arrayPageSize[0] - 20 - 220) / 2) + 'px');
	    $('ipd-msg-wrapper').style.display = 'block';
	    $('ipd-msg-text').innerHTML=msg
	    $('ipd-msg-wrapper').style.zIndex = '200'
	    window.setTimeout("hs('ipd-msg-wrapper','none')",2000)
	    
	    
}


function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}


	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}


function getPageScroll(){

	var yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
	}

	arrayPageScroll = new Array('',yScroll) 
	return arrayPageScroll;
}

	
	
	
	
	
	
	
	
	   //Check validate Email
   function validate_email(field)
{


apos=field.indexOf("@")
dotpos=field.lastIndexOf(".")
if (apos<1||dotpos-apos<2) 
  {

  return false
  }
else {

return true}

}
	
	
	
	      function popup(strURL,intWinW,intWinH)
{	
	
		var strProperties = "menubar=no, resizable=yes,  "; 


		var intScreenW = parseInt(screen.width, 10); 
		var intScreenH = parseInt(screen.Height, 10); 
		var intWinT = (intScreenH - intWinH)/2; 
		var intWinL = (intScreenW - intWinW)/2;
		strProperties += 'height=' + intWinH + ', width=' + intWinW + ', top=' + intWinT + ', left=' + intWinL + ', status=no,scrollbars=yes,toolbar=no,location=no'; 
		var winObject = window.open(strURL, 'PageServices', strProperties, false); 
//		var winObject=window.open("../services/postFeedbackAction.aspx","","height="+intWinH+",width="+intWinW+",status=no,toolbar=no,menubar=no,location=no,scrollbars=yes");
		winObject.focus(); 
	
}

