var sjl=new function(){	
	var explorer=navigator.userAgent.toLowerCase();
	var startValue=0;
	var endValue=0;
	var animID=0;

	this.Placeholder=function(id,val)
	{
		var ele=document.getElementById(id)
		ele.value=val;

		ele.onclick=function(){		
			if(ele.value==val){
				ele.value="";
			}
		}

		ele.onblur=function(){
			if(ele.value.length==0){
				ele.value=val;
			}
		}
	}

	this.ToggleDisplay1=function(element){
		var ele=document.getElementById(element);
		alert(ele.style.height);		
		if(ele.style.display=="none"){
			ele.style.display="block";		
		}else{
			ele.style.display="none";
		}
	}

	this.ToggleDisplay=function(element){		
		var ele=document.getElementById(element);
		height=ele.style.height.replace("px","");
		alert(height);
		ele.style.overflow="hidden";
		if(ele.style.display=="none"){
			ele.style.display="block";		
		}else{
			this.startValue=height;
			this.endValue=0;
			this.animID=setInterval("sjl.Animate("+element+")",1);		
		}
	}

	this.Animate=function(element){		
		if(this.startValue!=this.endValue){
			this.startValue=this.startValue-1;
			var ele=document.getElementById(element);
			element.style.height=this.startValue+"px";		
			document.getElementById('result').innerHTML=this.startValue+"==="+this.endValue;
		}else{
			this.stopAnimation();
			/*if(this.startValue==0){
				element.style.display="none";
			}*/
		}
	}

	this.stopAnimation=function(){
		clearInterval(this.animID);
	}

	this.IncreaseFontSize=function(id)
	{	
		var ele=document.getElementById(id);
		var current_font_size=ele.style.fontSize.replace("px","");
		current_font_size=parseInt(current_font_size);
		current_font_size++;			
		ele.style.fontSize=current_font_size+"px";
	}	

	this.DecreaseFontSize=function(id)
	{	
		var current_font_size=document.getElementById(id).style.fontSize.replace("px","");
		current_font_size=parseInt(current_font_size);
		current_font_size--;		
		document.getElementById(id).style.fontSize=current_font_size+"px";
	}	

	this.AJAX= function(url,result)
	{
		var xmlHttp;
		document.getElementById(result).innerHTML="";
		try{// Firefox, Opera 8.0+, Safari  
			xmlHttp=new XMLHttpRequest();  
		}
		catch (e){// Internet Explorer  
			try{   
			  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");    
			}catch (e){    
				try{
					xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");      
				}catch (e){      
					alert("Your browser does not support AJAX!");      
					return false;      
				}    
			}  
		}
		
		xmlHttp.onreadystatechange=function(){
			if(xmlHttp.readyState==4){			
				document.getElementById(result).innerHTML=xmlHttp.responseText;
			}
		}
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
	}

	this.DisableBackground=function()
	{
		var x=document.createElement('div');	
		x.setAttribute('id','sjl_background');
		x.setAttribute('style','display:block');
		document.body.appendChild(x);

		document.getElementById('sjl_background').style.position='absolute';
		document.getElementById('sjl_background').style.display='block';
		document.getElementById('sjl_background').style.top=0;
		document.getElementById('sjl_background').style.left=0;
		document.getElementById('sjl_background').style.zIndex="1";
		document.getElementById('sjl_background').style.background="#292929";

		if(document.body.scrollHeight>screen.height)
		{
			document.getElementById('sjl_background').style.height=document.body.scrollHeight+"px";
		}
		else
		{
			document.getElementById('sjl_background').style.height=screen.height+"px";
		}
		document.getElementById('sjl_background').style.width=document.body.clientWidth+"px";	
		document.getElementById('sjl_background').style.MozOpacity=.80;
		document.getElementById('sjl_background').style.opacity=.5;
		document.getElementById('sjl_background').style.filter="alpha(opacity = 50)";

		document.body.style.overflow="hidden";
	}

	this.PopupClose=function()
	{
	    document.getElementById('sjl_popup').style.display="none";
		document.body.removeChild(document.getElementById('sjl_popup'));
		document.body.removeChild(document.getElementById('sjl_background'));
		document.body.style.overflow="auto";
	}

	this.Popup=function(url,width,height)
	{	
		this.DisableBackground();
		
		var margin_left=(document.body.scrollWidth-width)/2;
		var margin_left=Math.round(margin_left);

		var sjl_margin_top=0;

		if(height=="undefined"){
			sjl_margin_top="10%";
		}else if(height=="flexi"){
			sjl_margin_top="10%";
		}else if(height=="fixed"){
			sjl_margin_top="10%";					
		}else{		    
		    //sjl_margin_top="635px";
		    //alert(screen.height);		    
			sjl_margin_top=(document.documentElement.clientHeight-height)/2;
			sjl_margin_top=Math.ceil(sjl_margin_top)+"px";
			//alert(sjl_margin_top);
		}


		var popup=document.createElement('div');	
		popup.setAttribute('id','sjl_popup');
		document.body.appendChild(popup);

		var title=document.createElement('div');
		title.setAttribute('id','sjl_title');
		document.getElementById('sjl_popup').appendChild(title);

		var body=document.createElement('div');	
		body.setAttribute('id','sjl_popup_body');
		document.getElementById('sjl_popup').appendChild(body);

		document.getElementById('sjl_title').innerHTML="<a href='javascript:sjl.PopupClose()' style='color:#ffffff; font:normal 12px verdana; text-decoration:none'>Close</a>";
		document.getElementById('sjl_title').style.marginBottom="5px";

		if(explorer.indexOf("msie")>-1)
			document.getElementById('sjl_popup').style.position='fixed';
		else
			document.getElementById('sjl_popup').style.position='fixed';

		document.getElementById('sjl_popup').style.zIndex='5';
		document.getElementById('sjl_popup').style.width=width+'px';
		
		//Set The Height of Popup
		if(height=='undefined' || height=='fixed'){
			document.getElementById('sjl_popup').style.height='80%';
		}else if(height=='undefined' || height=='flexi'){

		}else{
			document.getElementById('sjl_popup').style.height=height;
		}

		document.getElementById('sjl_popup').style.padding='10px';
		document.getElementById('sjl_popup').style.backgroundColor='#006699';
		document.getElementById('sjl_popup').style.borderRadius='5px';
		document.getElementById('sjl_popup').style.display='inline-block';	
		document.getElementById('sjl_popup').style.borderColor='#006699';
		document.getElementById('sjl_popup').style.border='1px solid #000';

		document.getElementById('sjl_popup_body').style.backgroundColor='#ffffff';	
		document.getElementById('sjl_popup_body').style.display='inline-block';
		document.getElementById('sjl_popup_body').style.borderRadius='5px';
		document.getElementById('sjl_popup_body').style.overflow='hidden';	
		document.getElementById('sjl_popup_body').style.height=document.getElementById('sjl_popup').clientHeight-40+"px";
				
		this.AJAX(url,'sjl_popup_body');
		
		document.getElementById('sjl_popup').style.top=sjl_margin_top;
		document.getElementById('sjl_popup').style.left=margin_left+"px";
	}

	this.sjlScrollUp=function(elem)
	{	
		if(Math.abs(pos)<elem.clientHeight-elem.parentNode.clientHeight)
		{
			pos--;		
			elem.style.top=pos+"px";
		}else{
			this.stopScroll();
		}	
	}

	this.sjlScrollDown=function(elem)
	{
		if(pos<0)
		{
			pos++;
			elem.style.top=pos+"px";
		}
		else
		{
			this.lstopScroll();
		}
	}

	this.stopScroll=function(){
		clearInterval(id);
	}

	this.sjlScroll=function(direction,elem){
		if(direction=='up'){				
			id=setInterval('this.sjlScrollUp1('+elem+')',10);
		}else{
			id=setInterval('this.sjlScrollDown('+elem+')',10);
		}
	}
}


