
function GetLeft(width)
{
	var sWidth= eval(parseInt(window.screen.width)-width);
	return eval(sWidth/2);
}

function GetTop(height)
{
	var	sHeigth= eval(parseInt(window.screen.height)-height);
	return eval(sHeigth/2);
}

function ValidateTextInput(textLength)
{
	var textBox=String.fromCharCode(event.keyCode);
	try
	{
		var Exp= new RegExp('[!@#$%^*+|()~`"<>/{}]');
		var result=Exp.exec(textBox);
		if(result!=null)
		{	
			return false;
		}
		if(textLength!=undefined)
		{
			
			if(eval(event.srcElement.value.length>=textLength))
			{	
				
				return false;
			}
			
		}
	}
	catch(e)
	{
		
	}
	return true;
}
function ValidateDropDown(s,e)
{
	if(s.selectedIndex<=-1)
	{
		e.IsValid=false;
	}
	else
	{
		if(s.options[s.selectedIndex].value==0)
		
		{
			e.IsValid=false;
		}
	}
	e.IsValid=true;
}

function openPopupImage(pagetitle,imageurl)
			{
				var imageWindow = window.open("","","scrollbars=no,resizable=no");
				imageWindow.document.writeln("<html><head><title>"+pagetitle+"<\/title>\n");
				imageWindow.document.writeln("<SCRIPT LANGUAGE=\"JavaScript\">");
				imageWindow.document.writeln("<!-- Begin\nfunction fitWindowSize() { var isNav4, isIE4; if (parseInt(navigator.appVersion.charAt(0)) >= 4) {");
				imageWindow.document.writeln("isNav4 = (navigator.appName == \"Netscape\") ? 1 : 0;");
				imageWindow.document.writeln("isIE4 = (navigator.appName.indexOf(\"Microsoft\") != -1) ? 1 : 0;}");
				imageWindow.document.writeln("if (isNav4) {window.innerWidth = document.layers[0].document.images[0].width;");
				imageWindow.document.writeln("window.innerHeight = document.layers[0].document.images[0].height;}");
				imageWindow.document.writeln("if (isIE4) {window.resizeTo(800, 600);");
				imageWindow.document.writeln("width = 800 - (document.body.clientWidth -  document.images[0].width);");
				imageWindow.document.writeln("height = 600 - (document.body.clientHeight -  document.images[0].height);");
				imageWindow.document.writeln("window.resizeTo(width, height);   } } \/\/  End -->");
				imageWindow.document.writeln("<\/script>");

				imageWindow.document.writeln("<body onLoad=\"fitWindowSize()\">");
				imageWindow.document.writeln("<script language=\"JavaScript\">");
				imageWindow.document.writeln("var message=\"Sorry, but you can't view the this menu!\";");
				imageWindow.document.writeln("function clickIE4(){if (event.button==2){alert(message);return false;}}");
				imageWindow.document.writeln("function clickNS4(e){if (document.layers||document.getElementById&&!document.all){if (e.which==2||e.which==3){alert(message);return false;}}}");
				imageWindow.document.writeln("if (document.layers){document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS4;}else if (document.all&&!document.getElementById){document.onmousedown=clickIE4;}");
				imageWindow.document.writeln("document.oncontextmenu=new Function(\"alert(message);return false\")<\/script>");
				imageWindow.document.writeln("<div style=\"position:absolute; left:0px; top:0px\">");
				imageWindow.document.writeln("<img src=\""+imageurl+"\" onload=\"fitWindowSize()\">");
				imageWindow.document.writeln("<br><\/div><\/body><\/html>");
		}
		
/* Commented by renuka on 16 jan2008 function UploadImage(PartNumber,ImageType,OperationMode,imglbl,imglnk,imgName,lnkRemoveUploadImage)
{
	//Image will be upload only if no image is there. 

	var removeLnk=lnkRemoveUploadImage;
	if(document.getElementById(removeLnk).id!=null && removeLnk!="" && removeLnk.length>0)
	   document.getElementById(removeLnk).disabled=false;
    
	 if(ImageType.indexOf('big')>-1)
	 {   
	 //alert('big');
//	    if(document.getElementById(imglnk).src.indexOf('notavail')>0)
//	    {
	         window.open("/CatalogUtility/UploadPartImage.aspx?PartNumber="+PartNumber+"&ImageType="+ImageType+"&OperationMode="+OperationMode+"&img="+imgName,"UploadImage","width=400,height=150,top="+GetTop(150)+",left="+GetLeft(400)+"");
	        
	         return false;
	  //  }
//	    else
//	        return false;
	 }
     else
     {
         if(document.getElementById(imglnk).src.indexOf('notavail')>0)
	    {
	        window.open("/CatalogUtility/UploadPartImage.aspx?PartNumber="+PartNumber+"&ImageType="+ImageType+"&OperationMode="+OperationMode+"&img="+imgName,"UploadImage","width=400,height=150,top="+GetTop(150)+",left="+GetLeft(400)+"");
	        return false;
  
	    }
	    else
	        return false;
       
    }   
}*/// ocmment ends by renuka
		
//function UploadImage(PartNumber,ImageType,OperationMode,imglbl,imglnk,imgName,lnkRemoveUploadImage)
//  {   alert('inside uploadimage');
//       /* defination for parameters
//        PartNumber conatins the Linecode+"_"+partnumber.
//        ImageType contains either big or thumb.
//        OperationMode contains either add or delete.
//        Image will be upload only if no image is there. 
//           imglbl is empty string
//           imglnk contains either imgBig or imgSmall(container for image).
//           imgName is empty
//           lnkRemoveUploadImage contains either lnkRemoveUploadImage or lnkRemoveThumbImage.*/
//            
//          var removeLnk=lnkRemoveUploadImage;
//                                                 
//         //Code for image type "big"
//         if(ImageType.indexOf('big')>-1)
//         { 
//            removeLnk=removeLnk.replace(/RemoveUploadImage/i,"lnkUploadBigImage");
//           
//            if(document.getElementById(removeLnk).disabled != false)            //If the lnkUploadBigImage button is not disable then open the CatalogUtility/UploadPartImage.aspx with ffg query string parameters listed below.Pop up open only if lnkUploadBigImage is not disabled.
//            window.open("/CatalogUtility/UploadPartImage.aspx?PartNumber="+PartNumber+"&ImageType="+ImageType+"&OperationMode="+OperationMode+"&img="+imgName,"UploadImage","width=400,height=150,top="+GetTop(150)+",left="+GetLeft(400)+"");
//            return false;
//         }
//          
//          //Code for image type "thumb"
//           else
//            {
//                 removeLnk=removeLnk.replace(/RemoveThumbImage/i,"lnkUploadThumbImage");                
//                
//                 if(document.getElementById(removeLnk).disabled != false)            //If the lnkUploadThumbImage button is not disable then open the CatalogUtility/UploadPartImage.aspx with ffg query string parameters listed below.Pop up open only if lnkUploadThumbImage is not disabled.
//                 window.open("/CatalogUtility/UploadPartImage.aspx?PartNumber="+PartNumber+"&ImageType="+ImageType+"&OperationMode="+OperationMode+"&img="+imgName,"UploadImage","width=400,height=150,top="+GetTop(150)+",left="+GetLeft(400)+"");
//                 return false;       
//            }   
//  }




function UploadImage(PartNumber,ImageType,OperationMode,imglbl,imglnk,imgName,lnkRemoveUploadImage)
  {   
       /* defination for parameters
        PartNumber conatins the Linecode+"_"+partnumber.
        ImageType contains either big or thumb.
        OperationMode contains either add or delete.
        Image will be upload only if no image is there. 
           imglbl is empty string
           imglnk contains either imgBig or imgSmall(container for image).
           imgName is empty
           lnkRemoveUploadImage contains either lnkRemoveUploadImage or lnkRemoveThumbImage.*/
         
          var removeLnk=lnkRemoveUploadImage;
          //Changes Made By: Akhilesh Bhale
          //Date:06/04/2008
          //Changes:To make ImageUpload link always enable(Big & Thumb on PromotionalParts) setting removeLnk.disabled to true.
              document.getElementById(removeLnk).disabled=true                                   
         //Code for image type "big"
         if(ImageType.indexOf('big')>-1)
         { 
            //removeLnk=removeLnk.replace(/RemoveUploadImage/i,"lnkUploadBigImage");
           
            if(document.getElementById(removeLnk).disabled != false)            //If the lnkUploadBigImage button is not disable then open the CatalogUtility/UploadPartImage.aspx with ffg query string parameters listed below.Pop up open only if lnkUploadBigImage is not disabled.
            window.open("/CatalogUtility/UploadPartImage.aspx?PartNumber="+PartNumber+"&ImageType="+ImageType+"&OperationMode="+OperationMode+"&img="+imgName,"UploadImage","width=400,height=150,top="+GetTop(150)+",left="+GetLeft(400)+"");
            return false;
         }
          
          //Code for image type "thumb"
           else
            {
                 //removeLnk=removeLnk.replace(/RemoveThumbImage/i,"lnkUploadThumbImage");                
                
                 if(document.getElementById(removeLnk).disabled != false)            //If the lnkUploadThumbImage button is not disable then open the CatalogUtility/UploadPartImage.aspx with ffg query string parameters listed below.Pop up open only if lnkUploadThumbImage is not disabled.
                 window.open("/CatalogUtility/UploadPartImage.aspx?PartNumber="+PartNumber+"&ImageType="+ImageType+"&OperationMode="+OperationMode+"&img="+imgName,"UploadImage","width=400,height=150,top="+GetTop(150)+",left="+GetLeft(400)+"");
                 return false;       
            }   
  }
  //new changes by Awanish Kaul for catalogbook/catalogpart.aspx
        function UploadImageForCatalogPart(PartNumber,ImageType,OperationMode,imglbl,imglnk,imgName,lnkRemoveUploadImage)
        {
	       
	      /* defination for parameters
	       PartNumber conatins the Linecode+"_"+partnumber.
	       ImageType contains either big or thumb.
	       OperationMode contains either add or delete.
	       Image will be upload only if no image is there. 
           imglbl is empty string
           imglnk contains either imgBig or imgSmall(container for image).
           imgName is empty
           lnkRemoveUploadImage contains either lnkRemoveUploadImage or lnkRemoveThumbImage.*/
	    		    	
	    	//find the lnkRemoveUploadImage button and make it enabled after finding out it.
			
			var removeLnk=lnkRemoveUploadImage;
	        if(document.getElementById(removeLnk).id!=null && removeLnk!="" && removeLnk.length>0)
	        document.getElementById(removeLnk).disabled=false;
	   
	        //Code for image type "big"
	        if(ImageType.indexOf('big')>-1)
	        {   
	            //alert(document.getElementById(imglnk).src);
	            if(document.getElementById(imglnk).src.indexOf('notavail')>0)
	            {
	                removeLnk=removeLnk.replace(/RemoveUploadImage/i,"UploadBigImage");
	               
	              
	                document.getElementById(removeLnk).removeAttribute('href');         //Remove the href attribute from lnkUploadBigImage button. 
	                document.getElementById(removeLnk).removeAttribute('onclick');      //Remove the onclick attribute from lnkUploadBigImage button. 
   	                document.getElementById(removeLnk).disabled=true;                   //Disable the lnkUploadBigImage button.
	                if(document.getElementById(removeLnk).disabled != false)            //If the lnkUploadBigImage button is not disable then open the CatalogUtility/UploadPartImage.aspx with ffg query string parameters listed below.Pop up open only if lnkUploadBigImage is not disabled.
	                window.open("/CatalogUtility/UploadPartImage.aspx?PartNumber="+PartNumber+"&ImageType="+ImageType+"&OperationMode="+OperationMode+"&img="+imgName,"UploadImage","width=400,height=150,top="+GetTop(150)+",left="+GetLeft(400)+"");
	                return false;
	            }
	            else
	            return false;
	       }
          
          //Code for image type "thumb"
           else
            {
                
                if(document.getElementById(imglnk).src.indexOf('notavail')>0)
	            {
	                removeLnk=removeLnk.replace(/RemoveThumbImage/i,"UploadThumbImage");
	                document.getElementById(removeLnk).removeAttribute('href');         //Remove the href attribute from lnkUploadThumbImage   button. 
	                document.getElementById(removeLnk).removeAttribute('onclick');      //Remove the href attribute from lnkUploadThumbImage   button. 
   	                document.getElementById(removeLnk).disabled=true;                   //Disable the lnkUploadThumbImage button.
	                if(document.getElementById(removeLnk).disabled != false)            //If the lnkUploadThumbImage button is not disable then open the CatalogUtility/UploadPartImage.aspx with ffg query string parameters listed below.Pop up open only if lnkUploadThumbImage is not disabled.
	                {
	                    window.open("/CatalogUtility/UploadPartImage.aspx?PartNumber="+PartNumber+"&ImageType="+ImageType+"&OperationMode="+OperationMode+"&img="+imgName,"UploadImage","width=400,height=150,top="+GetTop(150)+",left="+GetLeft(400)+"");
	                }
	                return false;
  
	            }
	            else
	            return false;
       
           }   
        }

 
var lblMsg;
var htmlEntity="<span style='color:blue;font-weight:bold'>&#187</span>";
var msg;
var timerID;

function UploadOn(Message,lblID)
{
	//alert('uploading');
	msg=Message;
	lblMsg=document.getElementById(lblID);
	MakeProgress(1);
}
function MakeProgress(index)
{

	
	if(index==1)
	{
		lblMsg.innerHTML=msg+ htmlEntity;
	}
	if(index==5)
	{
		lblMsg.innerHTML=msg;
		index=0;
	}
	else
	{
		lblMsg.innerHTML+=htmlEntity;
	}
	timerID=setTimeout("MakeProgress("+eval(index+1)+");",500);
}

function UploadOf()
{	
	clearInterval(timerID);
}
