function chkFormValid(id){
	var Err;
	Err="";
	var postForm=document.getElementById("postForm"+id);
	if(postForm.pment.value=="" || postForm.pname.value=="" || postForm.pname.value=="Name"){ 
		Err+="please fill name and comment \n";
	}
	if(postForm.ver.value=="" || postForm.ver.value=="Verification"){ 
		Err+="please enter verification number \n";
	}
	if(Err){
		alert(Err);
		return false;
	}else{
		return true;
	}
}
function swap(id,image){
	var element=document.getElementById(id);
	element.src=image;
}

var timeout=null;
fade=function(el,oNow,oTo,inc){
	var diff=Math.abs(oTo-oNow);
	if(diff>=Math.abs(inc)){ oNow+=inc; timeout=setTimeout("fade('"+el+"',"+oNow+","+oTo+","+inc+")",30); }
	else{ oNow=oTo; clearTimeout(timeout); }
	element=document.getElementById(el);
	element.style.opacity=oNow; //Safari
	element.style.filter="alpha(opacity="+oNow*100+")"; //ie
	
	if(oNow<=0){ element.style.visibility="hidden"; }
}

var timeoutScrollMent=null;
var doScrollY=false;
goY=function(y,t,el){
	doScrollY=true;
	var element=document.getElementById(el);
	var inc=Math.round((y-element.offsetTop)/t);
	element.style.top=element.offsetTop+inc+"px";
	timeoutScrollMent=setTimeout("goY("+y+","+t+",'"+el+"')",30);
	if(inc==0){ element.style.top=y+"px"; clearTimeout(timeoutScrollMent); doScrollY=false; }
}
var timeoutScrollImage=null;
var doScrollX=false;
goX=function(x,t,el){
	doScrollX=true;
	var element=document.getElementById(el);
	var inc=Math.round((x-element.offsetLeft)/t);
	element.style.left=element.offsetLeft+inc+"px";
	timeoutScrollImage=setTimeout("goX("+x+","+t+",'"+el+"')",30);
	if(inc==0){ element.style.left=x+"px"; clearTimeout(timeoutScrollImage); doScrollX=false; }
}

// Image

var timeoutTip=null;
var timeoutA=null; var timeoutB=null;
var mouseinImage=true;
onFocusImage=function(iFilterid,arrLid,arrRid){
	clearTimeout(timeout); 
	iFilter=document.getElementById(iFilterid);
	iFilter.style.visibility="hidden";
	arrL=document.getElementById(arrLid);
	arrL.style.visibility="visible";
	arrR=document.getElementById(arrRid);
	arrR.style.visibility="visible";
	fadeR(arrLid,0,0.8,0.1); 
	fadeL(arrRid,0,0.8,0.1); 
	mouseinImage=false;
}
outFocusImage=function(iFilterid,arrLid,arrRid){
	if( mouseinImage==false){
		clearTimeout(timeoutA); clearTimeout(timeoutB); 
		iFilter=document.getElementById(iFilterid);
		iFilter.style.visibility="visible";
		arrL=document.getElementById(arrLid);
		arrR=document.getElementById(arrRid);
		fadeR(arrLid,0.8,0,-0.1); 
		fadeL(arrRid,0.8,0,-0.1); 
		mouseinImage=true;
	}
}
fadeR=function(el,oNow,oTo,inc){
	var diff=Math.abs(oTo-oNow);
	if(diff>=Math.abs(inc)){ oNow+=inc; timeoutA=setTimeout("fadeR('"+el+"',"+oNow+","+oTo+","+inc+")",30); }
	else{ oNow=oTo; clearTimeout(timeoutA); }
	element=document.getElementById(el);
	element.style.opacity=oNow; //Safari
	element.style.filter="alpha(opacity="+oNow*100+")"; //ie
	
	if(oNow<=0){ element.style.visibility="hidden"; }
}
fadeL=function(el,oNow,oTo,inc){
	var diff=Math.abs(oTo-oNow);
	if(diff>=Math.abs(inc)){ oNow+=inc; timeoutB=setTimeout("fadeL('"+el+"',"+oNow+","+oTo+","+inc+")",30); }
	else{ oNow=oTo; clearTimeout(timeoutB); }
	element=document.getElementById(el);
	element.style.opacity=oNow; //Safari
	element.style.filter="alpha(opacity="+oNow*100+")"; //ie
	
	if(oNow<=0){ element.style.visibility="hidden"; }
	
	
}
scrollLft=function(iContainid,total){
	if(checkScrollImage("lft",iContainid,total) && doScrollX==false){
		clearTimeout(timeoutScrollImage);
		for(i=0;i<total;i++){
			var contain=document.getElementById(iContainid+"_"+i);
			var dest=contain.offsetLeft-552;
			goX(dest,5,iContainid+"_"+i);
		}
	}
}
scrollRht=function(iContainid,total){
	if(checkScrollImage("rht",iContainid,total) && doScrollX==false){
		clearTimeout(timeoutScrollImage);
		for(i=0;i<total;i++){
			var contain=document.getElementById(iContainid+"_"+i);
			var dest=contain.offsetLeft+552;
			goX(dest,5,iContainid+"_"+i);
		}
	}
}
checkScrollImage=function(direction,iContainid,total){
	var container=document.getElementById(iContainid+"_"+0);
	if(direction=="lft"){
		var maxLeft=552*(parseInt(total)-1)*-1;
		if(container.offsetLeft<=maxLeft){return false;}
		else{ return true; }
	}
	if(direction=="rht"){
		if(container.offsetLeft>=0){return false;}
		else{ return true; }
	}
}
showBig=function(imageid){
	var b=document.getElementById("bigImage");
	var bc=document.getElementById("bigImageContain");
	var bs=document.getElementById("bigImageScreen");
	var im=document.getElementById(imageid);
	var index=im.src.indexOf(".jpg")
	b.src="images/blank.png";
	b.src=im.src.substring(0,index)+"Big.jpg";
	bc.style.visibility="visible";
	bs.style.visibility="visible";
	fade("bigImageContain",0,1,0.2);
}
hideBig=function(){
	clearTimeout(timeout);
	fade("bigImageContain",1,0,-0.2);
	var bs=document.getElementById("bigImageScreen");
	bs.style.visibility="hidden";
	//var b=document.getElementById("bigImage");
}
initScreen=function() {
	var myWidth = 0, myHeight = 0;
	if( typeof( window.innerWidth ) == 'number' ) { //Non-IE
  		myWidth = window.innerWidth; myHeight = window.innerHeight;
	} 
	else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) { 	//IE 6+ in 'standards compliant mode'
 		myWidth = document.documentElement.clientWidth; myHeight = document.documentElement.clientHeight;
	} 
	else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) { //IE 4 compatible
  		myWidth = document.body.clientWidth; myHeight = document.body.clientHeight;
	}
	var bs=document.getElementById("bigImageScreen");
	bs.style.width= myWidth-20+"px";
	bs.style.height= myHeight+"px";
	var bc=document.getElementById("bigImageContain");
	bc.style.width= myWidth-20+"px";
	bc.style.height= myHeight+"px";
}

//descript
var timeooutScrollMask=null;
var doScrollMask=false;
scrollMask=function(y,t,el){
	doScrollMask=true;
	var element=document.getElementById(el);
	var inc=Math.round((y-element.offsetTop)/t);
	element.style.top=element.offsetTop+inc+"px";
	element.style.height=368-element.offsetTop+"px";
	timeooutScrollMask=setTimeout("scrollMask("+y+","+t+",'"+el+"')",30);
	if(inc==0){ 
		element.style.top=y+"px"; 
		element.style.height=368-y+"px"; 
		clearTimeout(timeooutScrollMask); doScrollMask=false; 
	}
}
formToggle=function(fContainid,fButtonid,dMaskid){
	clearTimeout(timeoutScrollMent);
	var contain=document.getElementById(fContainid);
	var button=document.getElementById(fButtonid);
	var mask=document.getElementById(dMaskid);
	if(mask.offsetTop>300){	// if form was not opened
		var dest=1;
		button.style.backgroundImage="url(files/closeBt.png)";
		button.innerHTML="";
		scrollMask(dest,5,dMaskid);
	}
	else{
		var dest=352;
		button.style.backgroundImage="none";
		button.innerHTML="Post your comment";
		scrollMask(dest,5,dMaskid);
	}
}
inputFocus=function(el){
	var element=document.getElementById(el);
	if(element.value==element.defaultValue){
		element.value="";
	}
	element.style.color="#000000";
}

// comment

var mousein=true;
onFocus=function(el){
	clearTimeout(timeout); 
	fade(el,0.8,0,-0.1); 
	mousein=false;
}
outFocus=function(el){
	if( mousein==false){
		clearTimeout(timeout); 
		fade(el,0,0.8,0.1);
		element.style.visibility="visible";
		mousein=true;
	}
}
scrollDown=function(mContainid){
	if( checkScroll("up",mContainid) && doScrollY==false){
		clearTimeout(timeoutScrollMent);
		var contain=document.getElementById(mContainid);
		var dest=contain.offsetTop+320;
		goY(dest,5,mContainid);
	}
}
scrollUp=function(mContainid){
	if( checkScroll("down",mContainid) && doScrollY==false){
		clearTimeout(timeoutScrollMent);
		var contain=document.getElementById(mContainid);
		var dest=contain.offsetTop-320;
		goY(dest,5,mContainid);
	}
}
checkScroll=function(direction,mContainid){
	var container=document.getElementById(mContainid);
	if(direction=="up"){
		if(container.offsetTop>=0){return false;}
		else{ return true;}
	}
	if(direction=="down"){
		var temp=(container.offsetTop*-1)+320
		if(container.offsetHeight<temp){return false;}
		else{ return true;}
	}
}

// page menu
pageMenuOn=function(id){
	var bt=document.getElementById(id);
	bt.style.background="#000";
	bt.style.color="#FFF";
}
pageMenuOut=function(id){
	var bt=document.getElementById(id);
	bt.style.background="#999999";
	bt.style.color="#FFF";
}
