function notBlank(myInput){

		if(myInput==""){
			return false; 
		}else{
			return true;
		}

}

function isNumber(myInput){

		if(isNaN(myInput)){
			return false; 
		}else{
			return true;
		}

}

function isEmail(myInput){
		
		  var supported = 0;
		  if (window.RegExp) {
			var tempStr = "a";
			var tempReg = new RegExp(tempStr);
			if (tempReg.test(tempStr)) supported = 1;
		  }
		  if (!supported) 
		  return (myInput.indexOf(".") > 2) && (myInput.indexOf("@") > 0);
		  var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
		  var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");

		  if(!r1.test(myInput)&&r2.test(myInput)){
		  		return true;
		  }else{
		  		return false;
		  }
		  
}

function isImage(myInput){

			if(myInput!='') {				
							FileType=myInput.substr(myInput.lastIndexOf('.'),4);
							FileType=FileType.toLowerCase();
							if(FileType=='.gif' || FileType=='.jpg' || FileType=='jpeg'){
									return true;
							}else{
									return false;
							};
			}else{
							return false;
			}
}

function isPassword(myInput,myInputConfirm){


				if((myInput==myInputConfirm)&&(myInput!="")){
						return true;
				}else{
						return false;
				};

}

function verifyCMSForm(myVerifyID){
		var verifyStatus=true;
		var myInputStr=document.getElementById(myVerifyID).value;
		var myInputArr=myInputStr.split('[@]');
		var noOfInput=myInputArr.length;
		
		if(noOfInput>0){
		
				for(i=0;i<noOfInput;i++){
					if(verifyStatus){					
							tempInputSubArr=myInputArr[i].split(':');			
							myInput=document.getElementById(tempInputSubArr[0]).value;
							switch(tempInputSubArr[1]){
								case 'notBlank':{ if(!notBlank(myInput)){ verifyStatus=false; }; break; }
								case 'isEmail' :{ if(!isEmail(myInput)) { verifyStatus=false; }; break; }
								case 'isImage' :{ if(!isImage(myInput)) { verifyStatus=false; }; break; }
							}
					}else{
							i=noOfInput;
					}
				}
						
		}else{
							tempInputSubArr=myInputStr.split(':');			
							myInput=document.getElementById(tempInputSubArr[0]).value;				
							switch(tempInputSubArr[1]){
								case 'notBlank':{ if(!notBlank(myInput)){ verifyStatus=false; }; break; }
								case 'isEmail' :{ if(!isEmail(myInput)) { verifyStatus=false; }; break; }
								case 'isImage' :{ if(!isImage(myInput)) { verifyStatus=false; }; break; }
							}
		}
		if(verifyStatus){
				document.getElementById('submit').style.display="";
		}else{
				document.getElementById('submit').style.display="none";
		}

}

function verifyForm(myVerifyID){
		var verifyStatus=true;
		var myInputStr=document.getElementById(myVerifyID).value;
		var myInputArr=myInputStr.split('[@]');
		var noOfInput=myInputArr.length;
		
		if(noOfInput>0){
		
				for(i=0;i<noOfInput;i++){
					if(verifyStatus){					
							tempInputSubArr=myInputArr[i].split(':');			
							myInput=document.getElementById(tempInputSubArr[0]).value;
							
							switch(tempInputSubArr[1]){
								case 'notBlank':{ if(!notBlank(myInput)){ alert(tempInputSubArr[2]); verifyStatus=false; }; break; }
								case 'isEmail' :{ if(!isEmail(myInput)) { alert(tempInputSubArr[2]); verifyStatus=false; }; break; }
								case 'isImage' :{ if(!isImage(myInput)) { alert(tempInputSubArr[2]); verifyStatus=false; }; break; }
								case 'isPassword' :{ myInputConfirm=document.getElementById(tempInputSubArr[0]+"_confirm").value; if(!isPassword(myInput,myInputConfirm)) { alert(tempInputSubArr[2]); verifyStatus=false; }; break; }
								
							}
					}else{
							i=noOfInput;
					}
				}
						
		}else{
							tempInputSubArr=myInputStr.split(':');			
							myInput=document.getElementById(tempInputSubArr[0]).value;				
							switch(tempInputSubArr[1]){
								case 'notBlank':{ if(!notBlank(myInput)){ alert(tempInputSubArr[2]); verifyStatus=false; }; break; }
								case 'isEmail' :{ if(!isEmail(myInput)) { alert(tempInputSubArr[2]); verifyStatus=false; }; break; }
								case 'isImage' :{ if(!isImage(myInput)) { alert(tempInputSubArr[2]); verifyStatus=false; }; break; }
								case 'isPassword' :{ myInputConfirm=document.getElementById(tempInputSubArr[0]+"_confirm").value; if(!isPassword(myInput,myInputConfirm)) { alert(tempInputSubArr[2]); verifyStatus=false; }; break; }
								
							}
		}
		document.getElementById(tempInputSubArr[0]).focus();
		return verifyStatus;

}

function selectItemAll(obj) {
	var Len = obj.options.length;
	if(Len>0) 
		for(var i=0;i<Len;i++)
		   obj.options[i].selected=true;
}


function moveItem(obj,direction){
	
	var total_items=obj.options.length;
	var tmpSwapValue,tmpSwapText;
	if(total_items>0){		
			
		if(direction=="down"){
								for(i=0;i<total_items;i++){
									if((obj.options[i+1]!=null)&&(obj.options[i].selected==true)){
										tmpSwapValue=obj.options[i].value;
										tmpSwapText=obj.options[i].text;
										obj.options[i].value=obj.options[i+1].value;
										obj.options[i].text=obj.options[i+1].text;
										obj.options[i].selected=false;
										
										obj.options[i+1].value=tmpSwapValue;
										obj.options[i+1].text=tmpSwapText;
										obj.options[i+1].selected=true;
										i=total_items;
									}				
								}								
		}else if(direction=="up"){
			
								for(i=1;i<total_items;i++){
									if((obj.options[i-1]!=null)&&(obj.options[i].selected==true)){
										tmpSwapValue=obj.options[i].value;
										tmpSwapText=obj.options[i].text;
										obj.options[i].value=obj.options[i-1].value;
										obj.options[i].text=obj.options[i-1].text;
										obj.options[i].selected=false;
										
										obj.options[i-1].value=tmpSwapValue;
										obj.options[i-1].text=tmpSwapText;
										obj.options[i-1].selected=true;
										i=total_items+1;
									}				
								}								

		}

		
	}
	
	
}
