﻿// JScript File

//Begin Check numeric functions
function checkNumeric(objName,minval, maxval,comma,period,hyphen)
{

	var numberfield = objName;
	if (chkNumeric(objName,minval,maxval,comma,period,hyphen) == false)
	{
		numberfield.select();
		numberfield.focus();
		return false;
	}
	else
	{
		return true;
	}
}

function chkNumeric(objName,minval,maxval,comma,period,hyphen)
{
// only allow 0-9 be entered, plus any values passed
// (can be in any order, and don't have to be comma, period, or hyphen)
// if all numbers allow commas, periods, hyphens or whatever,
// just hard code it here and take out the passed parameters
var checkOK = "0123456789" + comma + period + hyphen;
var checkStr = objName;
var allValid = true;
var decPoints = 0;
var allNum = "";


for (i = 0;  i < checkStr.value.length;  i++)
{
ch = checkStr.value.charAt(i);
for (j = 0;  j < checkOK.length;  j++)
if (ch == checkOK.charAt(j))
break;
if (j == checkOK.length)
{
allValid = false;
break;
}
if (ch != ",")
allNum += ch;
}
if (!allValid)
{	
alertsay = "Please enter only these values \""
alertsay = alertsay + checkOK + "\" in the \"" + checkStr.name + "\" field."
alert(alertsay);
return (false);
}

// set the minimum and maximum
var chkVal = allNum;
var prsVal = parseInt(allNum);
if (chkVal != "" && !(prsVal >= minval && prsVal <= maxval))
{
alertsay = "Please enter a value greater than or "
alertsay = alertsay + "equal to \"" + minval + "\" and less than or "
alertsay = alertsay + "equal to \"" + maxval + "\" in the \"" + checkStr.name + "\" field."
alert(alertsay);
return (false);
}
}
//  End -->


//replace any character with other.
function replaceAll( str, from, to ) 
        {
            var idx = str.indexOf( from );


            while ( idx > -1 ) {
                str = str.replace( from, to ); 
                idx = str.indexOf( from );
            }

            return str;
        }
//End replaceAll


//Collapse_Open()
function Collapse_Open(objID)
{
    //alert(objName);

    if(document.getElementById(objID).style.display=='none')
    {
        document.getElementById(objID).style.display='block';
    }
    else
    {
        document.getElementById(objID).style.display='none';
    }
}

function toggleDisplay(ObjID,imgID)
{
    var Obj=document.getElementById(ObjID);
	var displayStyle=Obj.style.display;
	var img=document.getElementById(imgID);
	//var img=event.srcElement;

	if(displayStyle=='none')
	{
		Obj.style.display='block';
		img.src="../Data/Common/Collapse.gif";
		img.alt="Collapse"
	
	}
	else
	{
		Obj.style.display='none';
		img.src="../Data/Common/Expand.gif";
		img.alt="Expand"
		  
	}
}

function toggleDisplay(ObjID)
{
     //alert(ObjID);
    var Obj=document.getElementById(ObjID);
	var displayStyle=Obj.style.display;
 
	if(displayStyle=='none')
	{
		
		Obj.style.display='block';
		
	}
	else
	{
		Obj.style.display='none';
		
	}
}
function toggleDisplay1(ObjID)
{
     //alert(ObjID);
    var Obj=document.getElementById(ObjID);
	var displayStyle=Obj.style.display;
    alert(displayStyle);
	if(displayStyle=='block')
	{
		
		Obj.style.display='none';
		
	}
	else
	{
		Obj.style.display='block';
		
	}
}
//Create Popup window //not working yet
function createPopupWindow(LocationX,LocationY,height,width,htmlFormat)
    {
    
    
        
        var oPopup = window.createPopup();
        var oPopupBody = oPopup.document.body;
        
        oPopupBody.innerHTML =htmlFormat ; 
        
       
         
         
        oPopup.show(LocationX, LocationY, height, width, document.body);
                    //x,y,height,width

//        if (oPopupBody.attributes.onload)
//        {
//                oPopupBody.attributes.onload.value += "window.print();";
//                
//                alert("true");
//                }
//        else
//        {
//                oPopupBody.setAttribute("onload", "alert('h');");
//                alert("false");
//                }
   
        //oPopupBody.style.border = "solid black 3px";      
        
    }

//Change Style functions
function ItemStyleOnMouseOver(objID)
    {
    
    //alert(document.getElementById(objID).innerHTML);
    
        //alert(objID.id);
        document.getElementById(objID.id).style.border=4;
        document.getElementById(objID.id).style.borderColor='black';
        document.getElementById(objID.id).style.backgroundColor='#cccccc';
        
    }
    
    function ItemStyleOnMouseLeave(objID)
    {
    
    //alert(document.getElementById(objID).innerHTML);
    
        //alert(objID.id);
        document.getElementById(objID.id).style.border=0;
        document.getElementById(objID.id).style.borderColor='black';
        document.getElementById(objID.id).style.backgroundColor='white';
        
    }
    //////////End style functions
    
    
    function popUp(PageName)
		{
		//t=document.body.scrollTop+event.clientY
		//l=document.body.scrollLeft+event.clientX
		//t=event.clientY
		//l=event.clientX
		var w = 800;
		var h = 800;
		l= (screen.width - w) / 2;
		t=(screen.height - h) / 2;
			
		//Result_window=window.open(PageName,'Magazine','width='+w+',top='+t+',left='+l+',height='+h+',scrollbars=yes,resizable=yes,status=no','');
		Result_window=window.open(PageName,'Magazine','','');
		Result_window.focus();
	
		}
		
		
////////////////
/////////////////
//////////////////
//////////////////get and set wwith cookies
    //var sessionId=<%= Session.SessionID %>;
// overWrite the value to remove sessionID to facilitate 
// Tracing while running many time , This line should be remove 

    

    

    /*

      The function is used to append the given value to the end of the comman sperated 

      value for the given variable name 

      If variable dose not exists , It will create it and assign given value to it 

    */

    function AppendToCookie(VariableName,value) 
    {
        if (CheckIfBrowserSupportCookie()==false)
        {
          alert('You must have cookies enabled in your browser to use this feature');
          return;
        }
        var temp="";
        temp=readCookie(VariableName);
        if (temp)// temp = Null I have to create it 
        {
            temp=temp+','+value;
        }
        else
        {
            temp=value;
        }
        var date = new Date();
        date.setTime(date.getTime()+(2*24*60*60*1000));
        var expires = "; expires="+date.toGMTString();
        document.cookie = VariableName+"="+temp+expires+"; path=/";

    }

    /*
    The function is used to read the value for this variable 
    */

    function readCookie(name) 
    {
      var nameEQ = name + "=";
      var ca = document.cookie.split(';');
      for(var i=0;i < ca.length;i++) 
      {
        var c = ca[i];
        while (c.charAt(0)==' ') c = c.substring(1,c.length); // Left trim
        if (c.indexOf(nameEQ) == 0) 
           return c.substring(nameEQ.length,c.length);
      }

          return null;
  }


    /*
    The function is used to check Does the given listID in the comma sperated value 
    for the given variable or not
    */
    function checkIfExists(VariableName,listID)
    {
        if (CheckIfBrowserSupportCookie()==false)
        {
          return false;
        }
        //VariableName=VariableName+"_"+sessionId;
        var temp=readCookie(VariableName);
        if (temp)
        {
          var ca = temp.split(',');
          for(var i=0;i < ca.length;i++) 
          {
            if(ca[i]==listID)
                {
                    return true;
                }
          }
          return false;
        }
        else
        {
          return false;
        }
    }

 

    /*
    The function is used to remove the given listid , from the comma separated
    value of the given variable 
    */

    function RemoveListingFromCookie(VariableName,listID)
    {
    
        if (CheckIfBrowserSupportCookie()==false)
        {
          alert('You must have cookies enabled in your browser to use this feature');
          return;
        }
        
        //VariableName=VariableName+"_"+sessionId;
        var temp2="";
        var temp=readCookie(VariableName);
        if (temp)
        {
          var ca = temp.split(',');
          for(var i=0;i < ca.length;i++) 
          {
            if(ca[i]!=listID)
            {
              if(temp2 !="")
              temp2=temp2+","+ca[i];
              else
              temp2=ca[i];
            }
          }

        var date = new Date();
        date.setTime(date.getTime()+(2*24*60*60*1000));
        var expires = "; expires="+date.toGMTString();
       
        //alert('Variable name at the end of rem listing from cooke = ' +temp2)
        document.cookie = VariableName+"="+temp2+expires+"; path=/";
       }
   }
   function CheckIfBrowserSupportCookie()
   {
       // IE and Netscape support cookieEnabled variable
       // Other browser will treat cookieEnabled as undefined varialbe 
       // here we handle different browser by checking both false and undefined 
     if (  (navigator.cookieEnabled== false)
         ||(navigator.cookieEnabled=="undefined"))
     {
       return false;
     }
     return true ;
   }
/////////////////
///////////////
////////////////End get and set wwith cookies

function nextnew()
    {
    var imgright= document.images['imgright'];
    var imgleft= document.images['imgleft'];
    
    if(arImages.length>4 && imgright.src.indexOf("rightarr.jpg")!=-1)
    {
       
       img1=document.getElementById('IMGs'+0);
       
       img1.src=arImages[4].src;
       
     
       img1=document.getElementById('IMGs'+1);
       if(arImages[5]!=null)//in case of 6 photos
       img1.src=arImages[5].src;
       else //in case of 5 photos
       img1.style.visibility= "hidden";
       
       img1=document.getElementById('IMGs'+2);
       img1.style.visibility= "hidden";
     
      
       img1=document.getElementById('IMGs'+3);
       img1.style.visibility= "hidden";
       
      imgright.src="../Data/Common/rightarrh.jpg";
      imgleft.src="../Data/Common/leftarr.jpg";
      
   }
  
 
 }
    function prevnew()
    {
    var imgright= document.images['imgright'];
    var imgleft= document.images['imgleft'];
  
     if(imgleft.src.indexOf("leftarr.jpg")!=-1)
         {
       img1=document.getElementById('IMGs'+0);
       img1.src=arImages[0].src;
       
       
       img1=document.getElementById('IMGs'+1);
       img1.src=arImages[1].src;
       img1.style.visibility= "visible";
       
       
       img1=document.getElementById('IMGs'+2);
       img1.src=arImages[2].src;
       img1.style.visibility= "visible";
      
       
        img1=document.getElementById('IMGs'+3);
        img1.style.visibility= "visible";
        img1.src=arImages[3].src;
       
    imgleft.src="../Data/Common/leftarrh.jpg";
    imgright.src="../Data/Common/rightarr.jpg";
        
   }
 }

  


