/*
    Designed and Coded by   : Shaik Zameer Ahmed (Software Programmer)      

    Functions Used: 8
            Element - form.element.name
            
            ex : If the the form name is "ThisForm"
                 element.name is "username"
                 
                 So the Element contains as (Thisform.username)
                 in the function.
                  
        
        Function 1: GenValidation(Element,Message1,Message2,spl)
        
            Message1: If you want to check the validation for the null 
                      or the element value is empty, what messge to be popped up.
                      
            Message2: If you want to check the validation for the element
                      length is less than 4, what messge to be popped up.
                      
            spl: Whether your element vlaue is to be checked for spl. characters                      
                      
            Usage  Details:
            
            Case 1: GenValidation(Element,'Message1','Message2','spl')
            
            Case 2: GenValidation(Element,'','','spl')
            
            Case 3: GenValidation(Element,'','Message2','spl')
            
            Case 4: GenValidation(Element,'','Message2','')
            
            Case 5: GenValidation(Element,'Message1','','spl')

            Case 6: GenValidation(Element,'Message1','','')
                
        Function 2: SplCharacters(Element)
                    
        Function 3: EmailValidation(Element)
        
        Function 4: SplNumbers(Element)
        
        Function 5: NumValidation(Element,'Message','spl','num')
        
        Function 6: SelectValidation(Element,'Message')
                This is to valid the select option values, 
                always use your first option value is equals to zero
        example:                
                <select>
                    <option value="0">select</option>
                    <option value="1">......</option>
                </select>
                
        Function 7: PassValidation(Element1,Element2)
                    Retype Password and Password matching
                    
        Function 8: DateValidation(dd,mm,yyyy,'msg')
                    dd, mm, yyyy are elements of the date either it can be 
                    combo box or text box.
                    Note:
                    Please pass the name of the field thru msg.
                    like "Start Date", "Date of Birth"
                    Furthermore, This function takes care of focus setting.

        Function 9: ValidDates(dd1,mm1,yyyy1,dd2,mm2,yyyy2,msg)
                    dd1,mm1,yyyy1 are elements of the date either it can be 
                    combo box.
                    dd2,mm2,yyyy2 are elements of the date either it can be 
                    combo box or text box.

        Function 10: SelectAll(form name)
                     
                     ex:-
                     <input type="checkbox" name="selectall" value="Select All" onclick="SelectAll(this.form);">
                 NOTE: The check box name should be "selectall"
                 
        Function 11: getSelectedIndex(radgroup)
                    This can used while validating radio button groups. If none of the buttons is selected then the function    
                    returns -1 else the id.
                    
                    E.g: frm is the name of a form and radSearchType is the radiobutton group name.
                    
                    if( getSelectedIndex(frm.radSearchType) == -1 )
                    {
                        alert("Please select search type." );
                        frm.radSearchType[0].focus();
                        return;
                    }
        Function 12: TextareaValidation(elem,msg,len)
                    This function can be used to validate the length of Text area's in forms.
                    For example...if the value of text area should not exceed 500 characters.
                    
                    Arguments :
                    elem : The element(TextArea)
                    msg : Message to be alerted
                          For example "Description"
                    len : No of characters not to be exceeded
                    
                    E.g: frm is the name of a form and desc is a text area name.
                    
                    Usage in form: 
                    if(TextareaValidation(frm.desc,'Description',500) == 0)
                    return;
                    
                    if(elem.value.length > len) {
                       alert(msg+" should not exceed "+len+" characters");
                       elem.focus();
                       return 0;
                    }           
                    
            Function 13 : Checkme(elem,msg)
                            Usage in form: 
                            if(Checkme(frm.agree,'You must agree to the terms and conditions') == 0)
                            return false;
            Function 14 : OnlyImageFileFormat(file_name)
                            checks only file format if file exist
    CODE META DATA ENDS_______________________________________________
*/

    /**
    FUNTION SELECTALL CHECK BOXES
    **/
    function SelectAll(frm) {
     //alert(frm.selectall.checked);
       if(frm.selectall.checked == true) {
       
         for(i=0;i<frm.elements.length;i++) {
           if((frm.elements[i].type == "checkbox") && (frm.elements[i].name != "selectall")) {
             frm.elements[i].checked = true;
           } // if statement
         } // for loop
       }
       else if(frm.selectall.checked == false) {
        
          for(i=0;i<frm.elements.length;i++) {
             if((frm.elements[i].type == "checkbox") && (frm.elements[i].name != "selectall")) {
               frm.elements[i].checked = false;
             } // if statement
          } // for loop
       } // if - else - if condition
    } // closing the function SelectAll()
    
    /**
     FUNCTION VALIDDATES
    **/
    function ValidDates(dd1, mm1, yyyy1, dd2, mm2, yyyy2, msg) {
    
     xFlag = 0;
     
     /*The Following Code has been commented by Ravi Julapalli
     if((DateValidation(dd1,mm1,yyyy1) == 0) && (DateValidation(dd2,mm2,yyyy2) == 0))*/
     
     // Start of Code Added by Ravi
     if((DateValidation(dd1,mm1,yyyy1,'null') == 0) || (DateValidation(dd2,mm2,yyyy2,'null') == 0))
        xFlag = 1;
     if(xFlag==1)
     {
       return 0
     }
     
     // End of Code Added by Ravi
     
        if(xFlag == 0) {
            var ddd1 = new Number(dd1.value) ;
            var mmm1 = new Number(mm1.value) - 1;
            var yyy1 = new Number(yyyy1.value);
            
            var ddd2 = new Number(dd2.value) ;
            var mmm2 = new Number(mm2.value) - 1;
            var yyy2 = new Number(yyyy2.value);
        
            var dObj1 = new Date(yyy1,mmm1,ddd1,0,0,0,0);
            var dObj2 = new Date(yyy2,mmm2,ddd2,0,0,0,0);
        
            if(dObj1 > dObj2) {
                alert(msg);
                dd1.focus();
                return 0;
            }
        }
        else 
            return 1;
    
    } // closing the function ValidDates()
    
        function dval(yyy,mmm,ddd) {
         
          var dObj = new Date(yyy,mmm,ddd,0,0,0,0);
        
          var dd = dObj.getDate();
          var mm = dObj.getMonth();
          var yy = dObj.getFullYear();
        
          if((dd == ddd) && (yy == yyy) && (mm == mmm)) {
            return true;
          }  
          else {
            return false;
          }
            
        } // closing the function dval()
    
    /**
     FUNCTION DATEVALIDATION(dd,mm,yy,msg) 
     **/
    function DateValidation(dd, mm, yy, msg) {
    
       
     if(NumValidation(dd,'Date','','num') == 0)
     return 0;
     
     if(NumValidation(mm,'Month','','num') == 0)
     return 0;
     
     if(NumValidation(yy,'Year','','num') == 0)
     return 0;
     
    
     
     d = parseInt(dd.value);
     m = parseInt(mm.value);
     y = parseInt(yy.value);
     
     if(m > 12 || m == 0) {
        alert("Invalid month selected for " + msg);
        mm.focus();
        return 0;
     }
     else {
     
     var vDays = [ 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 ];
     var flag = 0;
     if(m == 2) {
        if(isLeapYear(y)) {
          if( d > 29 || d < 1 ) {
           flag = 0;
          }
          else {
           flag = 1;
          }
        }
        else if( d > vDays[m] || d < 1 ) {
         flag = 0;
        }
        else {
             flag = 1;
        }
     }
     else {
        if( d > vDays[m] || d < 1 ) {
         flag = 0;
        }
        else {
         flag = 1;
        }  
     }
     }
     if(flag == 0) {
    
        alert("Invalid day selected for " + msg);
    
        dd.focus();
        return 0;
     }
     else {
        return 1;
     }
     
     
    } // closing the function DateValidation() 
    
    function isLeapYear(y) {
     if( y % 4 == 0) {
        if( y % 100 == 0 ) {
             if( y % 400 == 0) {
                  return true;
             }
             else {
                  return false;
             }
        }
        else {
            return true;
        }
     }
     else {
        return false;
     }
    } // closing the function isLeapYear()
     
    /**
     FUNCTION PASSVALIDATION(element1,element2) 
     **/
    
    function PassValidation(Element1,Element2)
    {
    
        if(Element1.value != Element2.value)
        {
            alert("Confirm Password doesn't match");
            Element2.focus();
            return 0;
        }
        else
            return 1;
        
    } // closing the function PassValidation()
    
    
    /**
     FUNCTION CONFIRMEMAILVALIDATION(element1,element2) 
     **/
    
    function ConfirmEmailValidation(Element1,Element2) {
    
        if(Element1.value != Element2.value) {
            alert("Confirm Email doesn't match");
            Element2.focus();
            return 0;
        }
        else
            return 1;
        
    } // closing the function ConfirmEmailValidation()
    
    /**
     FUNCTION Reorderlevel(Element1,Element2) 
     **/
    function Reorderlevel(Element1,Element2)
    {
        if(parseInt(Element1.value) < parseInt(Element2.value))
        {
            alert ("ReOrder Level should be less than Quantity Available");
            Element2.focus();
            return 0;
        }
    }


    /**
     FUNCTION SELECTVALIDATION(element,message) 
     **/

   function SelectValidation(Element,Message)
   {
        if(Element.value == "0")
        {
            alert("Please select "+Message);
            Element.focus();
            return 0;
        }
    
    }
    /**
     FUNCTION float validation(element) 
     **/
    function onlyfloat(objValue,mes)
    {
        var charpos = objValue.value.search("[^0-9.]"); 
        
        var splitvalue2 = objValue.value.split(".");
        var count= splitvalue2.length;
        var str=objValue.value.length

        if(objValue.value.length > 0 &&  charpos >= 0) 
        { 
                      
            alert(mes+": Only digits allowed " + "\n [Error character position " + eval(charpos+1)+"]");                
            return 0; 
          }//if 
          else if(count>1){
             var first= splitvalue2[0].length;
             var second=splitvalue2[1].length;
              if(count>2){
                  alert("Enter valid value");
                  
                  return 0;
              }
              
              if(first>3 || second>3)
               {
                  alert("Enter value in the format 000.000");
                    
                  return 0;
               }
             }
             else if(str>3)
                   {
                    alert("Enter value in the format 000.000");
                    return 0;
            }
            else
            {       
                return 1;
            }   
                  

    }
    
    /**
     FUNCTION EMAILVALIDATION(element) 
     **/
     
    function EmailValidation(Element)
    {
        Flag  = 1;
        count = 0;
    
        var alp = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_@.-";
        
        if(Element.value.length > 0)
        {
            for (var i=0; i<Element.value.length; i++)
            {
                temp = Element.value.substring(i, i+1);
    
                if (alp.indexOf(temp) == -1)
                {
                    Flag = 0;
                }
            } // closing the for loop
        }
        else
        {
            Flag = 0;
        }
    
        for(var i=0; i <= Element.value.length; i++)
        {
            if(Element.value.charAt(0)=='@')
            {
                Flag = 0;
                break;
            }

            if(Element.value.charAt(Element.value.length-1)=='@')
            {
                Flag = 0;
                break;
            }

            if(Element.value.charAt(i)=='@') 
            {
                count = count + 1;

                if(count>1)
                {
                    Flag = 0;
                    break;
                }
              
                if((Element.value.charAt(i-1)=='.') || (Element.value.charAt(i+1)=='.'))
                {
                    Flag = 0;
                    break;
                }
            }
            if(Element.value.indexOf('@')==-1)
            {
                Flag = 0;               
                break;
            }
            if(Element.value.charAt(0)=='.')
            {
                Flag = 0;
                break;
            }
            if(Element.value.indexOf('.')==-1)
            {
                Flag = 0;               
                break;
            }
          } //closing the for loop
        
        if(Element.value.charAt(Element.value.length-1) == '.')
            Flag = 0;
            
        if(Flag != 1)
        {
            alert("Invalid Email Address.");
            Element.focus();
            return 0;
        }   
        else
            return 1;
    }
    
    /**
     FUNCTION PAYPALVALIDATION(element) 
     **/
     
    function PaypalValidation(Element)
    {
        Flag  = 1;
        count = 0;
    
        var alp = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_@.-";
        
        if(Element.value.length > 0)
        {
            for (var i=0; i<Element.value.length; i++)
            {
                temp = Element.value.substring(i, i+1);
    
                if (alp.indexOf(temp) == -1)
                {
                    Flag = 0;
                }
            } // closing the for loop
        }
        else
        {
            Flag = 0;
        }
    
        for(var i=0; i <= Element.value.length; i++)
        {
            if(Element.value.charAt(0)=='@')
            {
                Flag = 0;
                break;
            }

            if(Element.value.charAt(Element.value.length-1)=='@')
            {
                Flag = 0;
                break;
            }

            if(Element.value.charAt(i)=='@') 
            {
                count = count + 1;

                if(count>1)
                {
                    Flag = 0;
                    break;
                }
              
                if((Element.value.charAt(i-1)=='.') || (Element.value.charAt(i+1)=='.'))
                {
                    Flag = 0;
                    break;
                }
            }
            if(Element.value.indexOf('@')==-1)
            {
                Flag = 0;               
                break;
            }
            if(Element.value.charAt(0)=='.')
            {
                Flag = 0;
                break;
            }
            if(Element.value.indexOf('.')==-1)
            {
                Flag = 0;               
                break;
            }
          } //closing the for loop
        
        if(Element.value.charAt(Element.value.length-1) == '.')
            Flag = 0;
            
        if(Flag != 1)
        {
            alert("Invalid Paypal Account");
            Element.focus();
            return 0;
        }   
        else
            return 1;
    }
    
    /**
     FUNCTION NUMVALIDATION(element,message,spl,onlynum) 
     **/
    function NumValidation(Element, MessageLen0, spl, OnlyNum)
    {
        if(MessageLen0.length != 0)
        {
            if(isBlank(Element.value) || Element.value.length == 0)
            {
                alert("Please enter "+ MessageLen0);
                Element.focus();
                return 0;
            }
        }
        
        if(OnlyNum == "num")
        {
            if(isNaN(Element.value))
            {
                alert("Please enter only Numeric Data");
                Element.focus();
                return 0;
            }
            if(parseInt(Element.value) < 0)
            {
                alert("Negative values are not allowed for this field.");
                Element.focus();
                return 0;
            }
        }
                
        if(spl == "spl" && OnlyNum != "num")
        {
            if(SplNumbers(Element) == 0)
            return 0;
        }   
    
    
    } // closing the function NumValidation()
    
    
    /**
     FUNCTION GENVALIDATION(element.message1,message2,spl) 
     **/
    
    function GenValidation(Element,MessageLen0,MessageLen4,spl) {
        
        if(MessageLen0.length != 0)
        {
            if(Element.value.length == 0)
            {
                alert("Please enter "+ MessageLen0);
                Element.focus();
                return 0;
            }
            else if(isBlank(Element.value))
            {
                alert("Please enter "+ MessageLen0);
                Element.focus();
                return 0;
            }
        }
    
        if(MessageLen4.length != 0)
        {
            if(Element.value.length < 4)
            {
                alert( MessageLen4 + " should be more than 4 characters");
                Element.focus();
                return 0;
            } // closing the if - else condtion for if(MessageLen4.length != 0)
        }
    
        if(spl == "spl")
        {
            if(SplCharacters(Element) == 0)
            return 0;
        }
        else if(spl == "space")
        {
            if(SplCharactersSpace(Element) == 0)
            return 0;
        }
        else if(spl == "nospace")
        {
            if(SplCharactersNoSpace(Element) == 0)
            return 0;
        }
        
    } // closing the function GenValidation()
    
    
    /**
     FUNCTION SPLCHARACTERS(element) 
     **/
    
    function SplCharacters(Val) {
    
    /***    updated by faiz***/
        //var alp = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_";
        
        var alp = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ";
    /*************************************/
        for (var i=0;i<Val.value.length;i++){
            temp=Val.value.substring(i,i+1);
            if (alp.indexOf(temp)==-1){
                alert("No special characters \nValid entries are [a-z][A-Z][ ]");
                Val.focus();
                return 0;
            }
        } // closing the for loop
    
    } // closing the function SplCharacters()
    
    /**
     FUNCTION SPLCHARACTERS(element) 
     **/
    
    function SplCharactersSpace(Val)
    {
        var alp = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 ";
    
        for (var i=0;i<Val.value.length;i++){
            temp=Val.value.substring(i,i+1);
            if (alp.indexOf(temp)==-1){
                alert("No special characters \nValid entries are [a-z][A-Z][0-9][ space ]");
                Val.focus();
                return 0;
            }
        } // closing the for loop
    } // closing the function SplCharactersSpace()
    
    function SplCharactersNoSpace(Val)
    {
        var alp = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.";
        alert('fasdfad');
        for (var i=0;i<Val.value.length;i++){
            temp=Val.value.substring(i,i+1);
            if (alp.indexOf(temp)==-1){
                alert("No special characters \nValid entries are [a-z][A-Z][0-9][.]");
                Val.focus();
                return 0;
            }
        } // closing the for loop
    } // closing the function SplCharactersNoSpace()
    
    /**
     FUNCTION SPLNUMBERS(element) 
     **/
    
    function SplNumbers(Val)
    {
        var alp = "0123456789+-";
    
        for (var i=0;i<Val.value.length;i++){
            temp=Val.value.substring(i,i+1);
            if (alp.indexOf(temp)==-1){
                alert("No special characters \nValid entries are [0-9][ + - ]");
                Val.focus();
                return 0;
            }
        } // closing the for loop
    
    } // closing the function SplNumbers()
    
    
    /**
     FUNCTION FOR CHECKING THE FIELD CONTAINS BLANK VALUES ISBLANK(Element.value)
     **/
    //To check if trim(value) is blank
function isBlank(txt, minlen)
{
    /*
        This fucntion can be used to check if a given text contains only spaces or 0 in length.

        INPUT: Text [txt]
                    Minimum Length [minlen] optional
                    Indicates that the text should be atleast 'minlen' in length

        OUTPUT: returns true if blank else false
    */

    if( txt.length == getCountOf('\n', txt) )
    {
        /*
            This condition avoids the entry of just newlines in text areas.
        */
        return true;
    }

    if( txt.length == getCountOf(' ', txt) || txt.length == 0 )
    {
        return true;
    }
    else if( minlen > 0 )
    {
        if( txt.length < minlen )
        {
            return true;
        }
        else
        {
            return false;
        }
    }
    else
    {
        return false;
    }
}
    
    //This can be used for any character validation.
    //For example in a valid date the count of - or / should not be more than 2
    //Likewise in a valid numer there should be only one .
    function getCountOf(vChr, txt)
    {
        var i = 0;
        var iCount = 0;
    
        for( i=0; i < txt.length; i++ )
        {
            if( txt.charAt(i) == vChr )
            {
                iCount++;
            }
        }
        return iCount;
    }
    
    
    function getSelectedIndex(radgroup)
    {
        /* Returns back the id of selected radio button in a radio button group  */
        var j = -1;
        for( i=0; i < radgroup.length; i++ )
        {
            if( radgroup[i].checked )
            {
                j = i;
            }
        }
        return j;
    }
    
    /**
     FUNCTION TEXTAREAVALIDATION(element,message,len) 

     **/
    
    function TextareaValidation(elem) {
    
           if(elem.value.length > 0)
           {
                if(isBlank(elem.value)) 
                {
                    alert("Please enter value ");
                    elem.focus();
                    return 0;
                }
                
           }
        
    } // closing the function TextareaValidation()
    
    
    function checkInCharSet(txt, charset)
    {
        /*
            This function checks if the characters in a given text are part of a given character set.
    
            INPUT:  Text ti be verified [txt]
                        String of character that forms the reference [charset]
    
            OUTPUT: Returns true if all of the characters in txt are part of charset, else false.
    
            USAGE:
                        for example:
    
                            checkInCharSet( "guru", "aeiouAEIOU" ) this fucntion returns false as "guru" contains 'g' and 'r'
                            whcih are not part of "aeiouAEIOU".
    
                            checkInCharSet( "abC", "abcdefABCDEF" ) this statement returns true as all "abC" contains characters
                            that are present in "abcdefABCDEF"
        */
    
        var b = true;
    
        for(i = 0; i < txt.length; i++ )
        {
            if( charset.indexOf(txt.charAt(i)) == -1 )
            {
                b = false;
            }
        }
    
        return b;
    }


    function isValidDate(dd, mm, yy)
    {
        /*
            This fucntion can be used for date validations.
    
            INPUT:  Day in numeric format [d]
                        Month in numeric format [m]
                        4 digit year [y]
    
            OUTPUT: Returns true if the date is valid else false.
    
            USAGE:
                        isValidDate( 1, 4, 2001 )   - Returns true
    
                        isValidDate( 1, 13, 2002 )  - Returns false coz month is > 12
                        
                        isValidDate( 30, 2, 2001)   - Returns false coz Feb will never have 30th
        */
    
        var d = parseInt(dd);
        var m = parseInt(mm);
        var y = parseInt(yy);
        
        if( isNaN(d) || isNaN(m) || isNaN(y) )
            return false;
            
        if( d <= 0 || m <= 0 || y <=0 )
            return false;
        
        if( d > 31 || m > 12 )
            return false;
    
        if( y < 1000 || y > 9999 )
            return false;
    
        var vDays = [ 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 ];
    
        if( m == 2 )
        {
            if( isLeapYear(y) )
            {
                if( d > 29 || d < 1 )
                {
                    return false;
                }
                else
                {
                    return true;
                }
            }
            else if( d > vDays[m] || d < 1 )
            {
                return false;
            }
            else
            {
                return true;
            }
        }
        else if( d > vDays[m] || d < 1 )
        {
            return false;
        }
        else
        {
            return true;
        }
    }
    
<!-- Begin
// var Message="www.Jewster.com"; 
var Message=" "; 
var place=1;
function scrollIn() 
{
    window.status=Message.substring(0, place);  
    if (place >= Message.length) 
    {
        place=1;
        window.setTimeout("scrollOut()",500); 
    } 
    else 
    {
        place++;
        window.setTimeout("scrollIn()",200); 
    } 
}
function scrollOut() 
{
    window.status=Message.substring(place, Message.length);
    if (place >= Message.length) 
    {
        place=1;
        window.setTimeout("scrollIn()", 300);
    } 
    else 
    {
        place++;
        window.setTimeout("scrollOut()", 200); 
    }
}
// End -->
// scrollIn() ; 
        /**
    FUNCTION ROUNDNUMBER(element)
    **/
    function RoundNumber(Val)
    {
        var alp = "0123456789";
    
        for (var i=0;i<Val.value.length;i++){
            temp=Val.value.substring(i,i+1);
            if (alp.indexOf(temp)==-1){
                alert("Invalid Quantity Entered.");
                Val.focus();
                return 0;
            }
        } // closing the for loop
    
    } // closing the function RoundNumber()

////////******** NAME VALIDATION ***************/////////////////
    function namevalidation(Val,charr)
    {
        if(Val.value=='')
        {
            alert('Please enter the '+charr);
            Val.focus();
            return false;
        }
        var alp = "!abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ";
        for (var i=0;i<Val.value.length;i++)
        {
            temp=Val.value.substring(i,i+1);
            if (alp.indexOf(temp)==-1)
            {
                alert("No special characters in "+charr+" \nValid entries are [a-z][A-Z][space]");
                Val.focus();
                return 0;
            }
        } // closing the for loop
    } //
    function alphabetic(objValue,charr){
         var charpos = objValue.value.search("[^A-Za-z ]"); 
         if(objValue.value.length > 0 &&  charpos >= 0) 
         { 
          strError= "No special characters in "+charr+". Valid entries are [a-z][A-Z][space]"                                 
          alert(strError + "\n [Error character position " + eval(charpos+1)+"]"); 
          objValue.focus();
          return false; 
         } 
    }
    
///////////////********************************//////////////////////////////   
function isValidEntry(element,msg) 
{
    if(element.value.length == 0)
    {
        alert("Please enter "+ msg);
        element.focus();
        return false;
    }
    else if(isBlank(element.value))
    {
        alert("Please enter "+ msg);
        element.focus();
        return false;
    }
    return true;
} 

function isValidConfirmPassword(element1,element2) 
{
    if(element1.value != element2.value)
    {
        alert("Confirm Password doesn't match");
        element2.focus();
        return false;
    }
    else
        return true;
}


function isValidZipcode(element,required) 
{
    var valid = "0123456789-";
    var hyphencount = 0;
    var field = element.value;
    var str   = required;
    if(field == "")
    {
        var rval = trim(required);
        if (rval.toLowerCase() == "yes" || rval == 1)
        {
            alert("Please enter ZipCode");
            element.focus();
            return false;
        }
    }   
    if (field != "")
    {
        if (field.length!=6 && field.length!=5 && field.length!=10) 
        {
            alert("Zip code length should be 6( forIndia) , or 5 (without hyphens) or 10 with Including Hyphens ( for USA)....");
            element.focus();
            return false;
        }
        for (var i=0; i < field.length; i++) 
        {
            temp = "" + field.substring(i, i+1);
            if (temp == "-") hyphencount++;
            if (valid.indexOf(temp) == "-1")
            {
                alert("Invalid characters in your zip code.  Please try again.");
                element.focus();
                return false;
            }
            if ((hyphencount > 1) || ((field.length==10) && "" + field.charAt(5)!="-")) 
            {
                alert("The hyphen character should be used with a properly formatted 5 digit+four zip code, like '12345-6789'.   Please try again.");
                element.focus();
                return false;
            }
        }
    }
    return true;
}

function EmailValidationFun(Element)
    {
        Flag  = 1;
        count = 0;
    
        var alp = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_@.-";
        
        if(Element.length > 0)
        {
            for (var i=0; i<Element.length; i++)
            {
                temp = Element.substring(i, i+1);
    
                if (alp.indexOf(temp) == -1)
                {
                    Flag = 0;
                }
            } // closing the for loop
        }
        else
        {
            Flag = 0;
        }
    
        for(var i=0; i <= Element.length; i++)
        {
            if(Element.charAt(0)=='@')
            {
                Flag = 0;
                break;
            }

            if(Element.charAt(Element.length-1)=='@')
            {
                Flag = 0;
                break;
            }

            if(Element.charAt(i)=='@') 
            {
                count = count + 1;

                if(count>1)
                {
                    Flag = 0;
                    break;
                }
              
                if((Element.charAt(i-1)=='.') || (Element.charAt(i+1)=='.'))
                {
                    Flag = 0;
                    break;
                }
            }
            if(Element.indexOf('@')==-1)
            {
                Flag = 0;               
                break;
            }
            if(Element.charAt(0)=='.')
            {
                Flag = 0;
                break;
            }
            if(Element.indexOf('.')==-1)
            {
                Flag = 0;               
                break;
            }
          } //closing the for loop
        
        if(Element.charAt(Element.length-1) == '.')
            Flag = 0;
            
        if(Flag != 1)
        {
            alert("Invalid Email Address.\nValid Characters [a-z][A-Z][0-9][ _ @ . -, ].\n\nlike prabhakar@harvest-technologies.com, naveen@harvest-technologies.com ...");
            //Element.focus();
            return 0;
        }   
        else
            return 1;
    }
    function Checkme(element, msg)
    {
        missinginfo = "";
        if (!element.checked)
        {
            missinginfo = msg;
        } 
        if (missinginfo != "")
        {
            missinginfo = missinginfo ;
            alert(missinginfo);
            return 0;
        }
        else
        { 
            return 1;
        }
    }
    
//this is example for radio button copied from zammy hrshop//   

function verifyIP (IPvalue) {
errorString = "";
theName = "IPaddress";

var ipPattern = /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/;
var ipArray = IPvalue.match(ipPattern);

if (IPvalue == "0.0.0.0")
    errorString = errorString + theName + ': '+IPvalue+' is a special IP address and cannot be used here.';
else if (IPvalue == "255.255.255.255")
    errorString = errorString + theName + ': '+IPvalue+' is a special IP address and cannot be used here.';
if (ipArray == null)
    errorString = errorString + theName + ': '+IPvalue+' is not a valid IP address.';
else 
{
    for (i = 0; i < 4; i++) 
    {
        thisSegment = ipArray[i];
        if (thisSegment > 255) 
        {
            errorString = errorString + theName + ': '+IPvalue+' is not a valid IP address.';
            i = 4;
        }
        if ((i == 0) && (thisSegment > 255)) 
        {
            errorString = errorString + theName + ': '+IPvalue+' is a special IP address and cannot be used here.';
            i = 4;
        }
    }
}
extensionLength = 3;
if (errorString != "")
{
    alert (errorString);
    return 0;
}

}
// function  to validate whether a given file is flv or not////////////////////////////////////
function videoFileFormat(file_name)
{

 var filename=file_name;
        if(filename=='')
        {
                alert('Please select a video file');
                return 0;
        }
        else
        {
               var firstdot=filename.indexOf('.');
               var lastdot=filename.lastIndexOf('.');
               if(firstdot!=lastdot)
               {
                     alert('Please check the video file path');
                     return 0;
               }
               else
               {
                     var subname=filename.substr(firstdot,4);
                     var lsubname=subname.toLowerCase(subname);
                    
                     if(lsubname=='.avi' || lsubname=='.dat' || lsubname=='.mpe' || lsubname=='.mpeg' || lsubname=='.mpg'|| lsubname=='.asf')
                     {
                        return 1;   
                     }
                     else
                     {
                         alert('File format does not support! Please choose proper file.');
                         return 0;
                     }
               }
        }
}


function flvFileFormat(file_name)
{

 var filename=file_name;
        if(filename=='')
        {
                alert('Please select a music file');
                return 0;
        }
        else
        {
               var firstdot=filename.indexOf('.');
               var lastdot=filename.lastIndexOf('.');
               if(firstdot!=lastdot)
               {
                     alert('Please check the music file path');
                     return 0;
               }
               else
               {
                     var subname=filename.substr(firstdot,4);
                     var lsubname=subname.toLowerCase(subname);
                     if(lsubname!='.flv')
                     {
                            alert('File format does not support! Please choose flv file.');
                            return 0;
                     }
               }
        }
}
function ImageFileFormat(file_name)
{
 var filename=file_name;
        if(filename=='')
        {
                alert('Please select an image ');
                return 0;
        }
        else
        {
               var firstdot=filename.indexOf('.');
               var lastdot=filename.lastIndexOf('.');
               if(firstdot!=lastdot)
               {
                     alert('Please check the image path');
                     return 0;
               }
               else
               {
                     var subname=filename.substr(firstdot,5);
                     var lsubname=subname.toLowerCase(subname);
                     if(lsubname == '.gif' || lsubname == '.jpeg' || lsubname == '.jpg' || lsubname == '.png')
                     {
                            return 1;
                     }
                     else
                     {
                        alert('Please choose gif (or) jpeg (or) png file.');
                            return 0;
                     }
               }
        }
}
function OnlyImageFileFormat(file_name)// added by vaibhav on 22-12-2008
{
   if(file_name=="")
       return -1;
   var filename=file_name;
   var firstdot=filename.indexOf('.');
   var lastdot=filename.lastIndexOf('.');
   if(firstdot!=lastdot)
   {
         alert('Please check the image path');
         return 0;
   }
   else
   {
         var subname=filename.substr(firstdot,5);
         var lsubname=subname.toLowerCase(subname);
         if(lsubname == '.gif' || lsubname == '.jpeg' || lsubname == '.jpg' || lsubname == '.png')
         {
                return 1;
         }
         else
         {
            alert('Please choose gif (or) jpeg (or) png file.');
                return 0;
         }
   }
        
}
/////////////////////// Mp3 file format ///////////////////////////////////////
function mp3FileFormat(file_name)
{
 var filename=file_name;
        if(filename=='')
        {
                alert('Please select a mp3 file');
                return 0;
        }
        else
        {
               var firstdot=filename.indexOf('.');
               var lastdot=filename.lastIndexOf('.');
               if(firstdot!=lastdot)
               {
                     alert('Please check the music file path');
                     return 0;
               }
               else
               {
                     var subname=filename.substr(firstdot,4);
                     var lsubname=subname.toLowerCase(subname);
                     if(lsubname!='.mp3')
                     {
                            alert('File format does not support! Please choose mp3 file.');
                            return 0;
                     }
               }
        }
}

/////////////////////// Check countries ///////////////////////////////////////
function checkUserCountry(selctry,memctry,memctryname,path)
{
 //alert(selctry+","+memctry+","+memctryname);
               if(memctry=="" ||(selctry == memctry) || (!memctry && !memctryname)){
                    document.frm_cart1.action = path
                    document.frm_cart1.submit();
                    return true;
               }else{
                    alert("You can buy vouchers from '"+memctryname+"' only!");
                    return false;
               }
}
/////////////////////// Copy Right's Owners///////////////////////////////////////
function copyOptions(obj,src){
    var n = src.options.length;
    obj.options.length = 0;
    for(var i=0;i<n;i++){
        if(src.options[i].selected){
            obj.options[obj.options.length] =new Option(src.options[i].text,src.options[i].value);
        }
    }
}

function showdiv(id)
{
    if(id==1)
    {
        document.getElementById('divIDnew').style.display='';
        document.getElementById('divIDnew').style.zIndex='999';
        document.getElementById('voucher_code').value="";
        document.getElementById('voucher_pin').value="";
    }
    else
       document.getElementById('divIDnew').style.display='none';    
}
function showDiv(id,total)
{
    for(var i=1;i<=total;i++)
    {
        document.getElementById('divMenu_'+i).style.display='none';
        document.getElementById('gap_'+i).style.display='none';
    }
        document.getElementById('divMenu_'+id).style.display='';
        document.getElementById('gap_'+id).style.display='';
}

/*Copied from header.php*/
function go_Search()
{
    window.location.href="?page_id=results&p_id=1";
}

function setCountry(val)
{
    document.frmCountry.submit();
}


function countrychange(myacc,country,c_id,value)
{
    if(myacc=="mycart"){
        var val=confirm("You can buy items only from your country "+country+". So you are now leaving the cart page for selected country store, click ‘Ok’ to proceed and ‘Cancel’ to continue shopping");
        if(val){            
            document.getElementById('changecountry').value=1    
            return true;            
        }else{
            document.getElementById('slctCountry').value=c_id
            return false;
        }
        
    }if(myacc=="play" || myacc=="play2"){
        var val=confirm("Are you sure you want to change the country?");
        if(val){            
            document.getElementById('changecountry').value=1    
            return true;            
        }else{
            document.getElementById('slctCountry').value=c_id
            return false;
        }
    }
    else{
        return true;
    }
}


function activateVoucher()
{
    var Uname=document.getElementById('user_name').value;
    var Type=document.getElementById('slt_voucherType').value;
    var Code=document.getElementById('voucher_code').value;
    var Pin=document.getElementById('voucher_pin').value;
    if(Uname=="")
    {
        alert("Please enter user name.");
        document.getElementById('user_name').focus();
        return false;
    }
    if(Type=="")
    {
        alert("Please select voucher.");
        document.getElementById('slt_voucherType').focus();
        return false;
    }
    if(Code=="")
    {
        alert("Please enter serial number.");
        document.getElementById('voucher_code').focus();
        return false;
    }
    if(Pin=="")
    {
        alert("Please enter pin number.");
        document.getElementById('voucher_pin').focus();
        return false;
    }
    var urlval = 'innerphp/ajax_server.php?user_name2='+Uname+'&vou_code='+Code+'&vou_type='+Type+'&vou_pin='+Pin;
    //alert(urlval);
    /*
    alert(urlval);
    ajax.requestFile = urlval;
    ajax.onCompletion = getResponse;
    ajax.runAJAX();
    */
    urlval = encodeURI(urlval);
    actVoucher(urlval);
}
function getResponse()
{
    eval(ajax.response);
}

function toggleText()
{
    if(document.getElementById("check_suggetion").checked==true)
    {
       document.getElementById("txt_allWords").readOnly=false;
       document.getElementById("txt_exact_phrase").readOnly=false;
       document.getElementById("txt_oneWord").readOnly=false;
       document.getElementById("txt_withoutWord").readOnly=false;
       document.getElementById("txt_allWords").focus();
    }
    if(document.getElementById("check_suggetion").checked==false)
    {
        document.getElementById("txt_allWords").value="";
        document.getElementById("txt_exact_phrase").value="";
        document.getElementById("txt_oneWord").value="";
        document.getElementById("txt_withoutWord").value="";
        document.getElementById("txt_allWords").readOnly=true;
        document.getElementById("txt_exact_phrase").readOnly=true;
        document.getElementById("txt_oneWord").readOnly=true;
        document.getElementById("txt_withoutWord").readOnly=true;
    }
    return true;
}


function disp_categories(){
    if(document.getElementById("radio_category_select").checked==true){
       document.getElementById("sel_category").style.display="";
       return false;
    }
    if(document.getElementById("radio_category_select").checked==false){
       document.getElementById("sel_category").style.display="none";
       return false;
    }
}
function disp_media_category(media_id){
    if(media_id==1){
        for(var i=1;i<=5;i++){
            if(document.getElementById("tr_"+i)!=null){
                if(document.getElementById("cnt_type"+i).value==1 || document.getElementById("cnt_type"+i).value==3){
                    document.getElementById("tr_"+i).style.display='';
                }else{
                    document.getElementById("tr_"+i).style.display='none';
                }
            }
        }
    }else if(media_id==2){
        for(var i=1;i<=5;i++){
            if(document.getElementById("tr_"+i)!=null){
                if(document.getElementById("cnt_type"+i).value==2 || document.getElementById("cnt_type"+i).value==4){
                    document.getElementById("tr_"+i).style.display='';
                }else{
                    document.getElementById("tr_"+i).style.display='none';
                }
            }
        }
    }
}

function searchSubmit(){
    document.frmCountry.action = 'index.php?page_id=search_result';
    document.getElementById('itemsearch').value = document.getElementById('itemsearch2').value
    document.frmCountry.submit();

}
function getIntoCart_2(Media_ID,country,memcountry,count,cartc){
    if(memcountry==0 || country==memcountry){
        document.getElementById('Media_ID').value=Media_ID;
        /* alert(document.getElementById('Media_ID').value); */
        if(count==0 && cartc==0 ){
            document.frm_buy.submit();  
        }else if(cartc!=0){
            var val= confirm("You have already selected this item in this order, are you sure you want to purchase it again?");
            if(val==true){
                document.frm_buy.submit();  
            }else{
                return false;
            }
        }else if(count!=0){
            var val= confirm("You have already purchased this item, are you sure you want to purchase it again?");
            if(val==true){
                document.frm_buy.submit();  
            }else{
                return false;
            }
        }
    }else{
        alert("This item is not available for sale in your country of registration");
        return false;
    }
}

function getIntoCart_1(country,memcountry,count){
    if(memcountry==0 || country==memcountry){
        if(count==0){
            document.frm_buy.submit();  
        }else{
            var val= confirm("You have already purchased this item, are you sure you want to purchase it again?");
            if(val==true){
                document.frm_buy.submit();  
            }else{
                return false;
            }
        }
    }else{
        alert("This item is not available for sale in your country of registration");
        return false;
    }
}

function toggle(id){
    if(document.getElementById(id).style.display=='none'){
        document.getElementById('txtAreaComment').value='';
        document.getElementById(id).style.display='';
        return false;
    }
    if(document.getElementById(id).style.display==''){
        document.getElementById(id).style.display='none';   
        return false;
    }
}
//////////////// Rating through ajax /////////////////////////
//ajax = new sack();
function fnctRatings(contId,membr){
    var rating=document.getElementById('hiddenRate').value;
    var comment=document.getElementById('txtAreaComment').value;
    if(rating!=0){
        ajax.requestFile= 'innerphp/ajax_server_comments.php?Rating='+rating+'&Comment='+comment+'&Cont_ID='+contId+'&Membr='+membr;
        ajax.onCompletion = dispInfo;
        ajax.runAJAX();
    }
}
function add_favs(cid,mid){
    ajax.requestFile= 'innerphp/ajax_server.php?cid='+cid+'&Mid='+mid;
    ajax.onCompletion = dispInfo;
    ajax.runAJAX();
}
function dispInfo(){
    eval(ajax.response);
}

/////////////////////////////////////////////////////////////

////////////////// clickRate ////////////////////////////
function clickRate(id,total){
    var tot=0;
    if(document.getElementById('img_rating_'+id).src.indexOf('images/greystar.gif')!=-1){
        for(var i=1; i<=id; i++){
            document.getElementById('img_rating_'+i).src='images/star_red.gif';     
        }
    } else{
        for(var j=id+1; j<=total; j++){
            document.getElementById('img_rating_'+j).src='images/greystar.gif';
        }
    }
    for(var k=1;k<=total; k++){
        if(document.getElementById('img_rating_'+k).src.indexOf('images/star_red.gif')!=-1){
            tot++;
        }   
    }
    document.getElementById('hiddenRate').value=tot;
}
///////////////////Entityt details//
function gotoEntity(eid,typ,eORa,ent_id){
    document.getElementById('eid').value=eid;
    document.getElementById('typ').value=typ;
    document.getElementById('eORa').value=eORa;
    document.getElementById('ent_id').value=ent_id;
    document.EntitySearch.action ='?page_id=headings';
    document.EntitySearch.submit();
}
///////////////////
///////////// Pagination //////////// 
function pageLoad(){
    document.cust_review.submit();
}
function pagination(pageid){
    contId=document.getElementById('cont_id').value;
    document.getElementById('page_no').value=pageid;
    if(pageid!=""){
        ajax.requestFile= 'innerphp/ajax_server_comments.php?page_no='+pageid+'&Cont_ID1='+contId;
        ajax.onCompletion = dispInfo;
        ajax.runAJAX();
    }
}
function dispPlayer_Info(){
    eval(ajax.response);
}

function submitFilter(){return(false)}     //Do nothing function

function showchage(json){
         alert('mmm'+json.result)
}

function shownews(id,top, con){
             var newsdiv = document.getElementById('tbl_address')
             if(!con){
                 var newsdisplay = newsdiv.style.display
                 if(newsdisplay != 'none'){
                      return(false)
                  }
                 else document.getElementById('click_over').value='over'
             }
             else document.getElementById('click_over').value='click'
             var nextbutton = document.getElementById('nextbutton')
             var previousbutton = document.getElementById('previousbutton')
             if(id==0) previousbutton.style.display='none'
             else previousbutton.style.display='inherit'
             var itemcount = document.getElementById('itemcount').value
             if(id==itemcount) nextbutton.style.display='none'
             else nextbutton.style.display='inherit'
            var mrg = findObjPos(top)
            var newspos = document.getElementById('newsitem'); newspos.value = id
            var newsheader = document.getElementById('newsheader'); var newsbody = document.getElementById('newsdump')
            var headid = 'head'+id; var bodyid = 'news'+id
            var headdiv = document.getElementById(headid); var contentdiv = document.getElementById(bodyid)
            newsheader.innerHTML = headdiv.innerHTML; newsbody.innerHTML = contentdiv.innerHTML
            newsdiv.style.display='';
            newsdiv.style.position = 'absolute';
            newsdiv.style.top = mrg.top-200+'px';
            newsdiv.style.left = mrg.left-500+'px'
            slowly.setOpacity(document.getElementById("tbl_address"), opacity);
            document.getElementById("tbl_address").style.opacity=96;
            newsheader.focus()
            return(false)
}

function shownews_2(id,top, con){
            var newsdiv = document.getElementById('tbl_address')
            if(!con){
                 var newsdisplay = newsdiv.style.display
                 if(newsdisplay != 'none'){
                      return(false)
                  }
                 else document.getElementById('click_over').value='over'
            }
            else document.getElementById('click_over').value='click'
            var nextbutton = document.getElementById('nextbutton')
            var previousbutton = document.getElementById('previousbutton')
            if(id==0) previousbutton.style.display='none'
            else previousbutton.style.display='inherit'
            var itemcount = document.getElementById('itemcount').value
            if(id==itemcount) nextbutton.style.display='none'
            else nextbutton.style.display='inherit'
            var mrg = findObjPos(top)   //Redundand for now
            var newspos = document.getElementById('newsitem'); newspos.value = id
            var newsheader = document.getElementById('newsheader'); var newsbody = document.getElementById('newsdump')
            var headid = 'head'+id; var bodyid = 'news'+id
            var headdiv = document.getElementById(headid); var contentdiv = document.getElementById(bodyid)
            newsheader.innerHTML = headdiv.innerHTML; newsbody.innerHTML = contentdiv.innerHTML
            newsdiv.style.position = 'absolute';
            var postop = mrg.top-200
            var posleft = (mrg.left+300)%1000
            newsdiv.style.top = postop+'px';
            newsdiv.style.left = posleft+'px'
            newsdiv.style.display='';
            slowly.setOpacity(document.getElementById("tbl_address"), opacity);
            document.getElementById("tbl_address").style.opacity=96;
            newsheader.focus()
            return(false)
}

function nextnews(direction,type){
            var id=document.getElementById('newsitem').value;
             if(direction)id++; else id--
            var headid = 'head'+id
            var headobj = document.getElementById(headid)
            if(type==1) shownews(id,headobj,true)
            else if(type==2) shownews_2(id,headobj,true)
            return(false)
}

function hidenewsdiv(){
         var click_over = document.getElementById('click_over').value
         if(click_over=='over'){
             var newsdiv = document.getElementById('tbl_address');
             newsdiv.style.display='none';
             return
         }
}

function findObjPos(obj) {
        var curleft = curtop = 0;
        if (obj.offsetParent) {
           do {
              curleft += obj.offsetLeft;
              curtop += obj.offsetTop;
           } while (obj = obj.offsetParent);
           return {left:curleft,top:curtop};
        }
       
}

function start_player(){
         var player = $('player_body')
//         var mrg = findObjPos(player)
//alert(mrg.top)
         var silver_player = $('hideplayer')
//         silver_player.style.position ='relative'
         player.style.display="none"
//         silver_player.style.top = mrg.top+'px'
//         silver_player.style.left = mrg.left+'px'
         silver_player.style.display=""
         //player.innerHTML = silver_player.innerHTML
}
function change_player(json){
     if(json.result){
         var player = $('player_body')
         player.style.display='none'
         var silver_player = $('hideplayer')
         silver_player.innerHTML = json.silverlight
         silver_player.style.display=''
         if(json.type==4){
                $('item_name').innerHTML = json.series_name;
                $('season_num').innerHTML = json.season;
                $('episode_num').innerHTML = json.episode;
         }else{
                $('rec_com').innerHTML = json.rec_com
         }
         $('item_name').innerHTML = json.item_name
        var cur_sym = $('itemcur').innerHTML
        $('onclickk').innerHTML = json.onclickk
        $('itemcur').innerHTML=cur_sym        
        if(json.price=='Free') $('itemcur').style.display='none'
        else $('itemcur').style.display=''
      //   $('itemprice').innerHTML = json.price;
     }else alert('System Error')
     return false
}

//BROWSER FUNTIONS
function browse_change(num){
          var Alpha = 'ALL'//num
          $('page_ajax_tracker').value=='9999'//LOCK
          alphabet_Filter(Alpha)  //AJAX CAll
          update_query(0,-1,-1)
}
//BROWSER FUNTIONS
function get_browse_items(alpha,page,row){
          $('page_special').value=1
          load_alphabet(alpha,page,row)
}
//BROWSER FUNTIONS
function alphabet_Filter(Alpha) {
             if($('page_ajax_tracker').value=='9999'){
                  return(false)
             }
             $('page_ajax_tracker').value= Alpha
             var cur_col =$('td_'+Alpha)
             var present_col_id = $('alphabet_sel').value
             var td_clicked = 'td_'+Alpha; $('alphabet_sel').value = td_clicked
             $(present_col_id).className = "browse-alphabet-td-normal"
             $(cur_col).className = "browse-alphabet-td-selected"
             $(present_col_id).style.bgcolor= '#FFFFFF'
             $(cur_col).style.bgcolor = "#F0F0F0"
             load_alphabet(Alpha,-1,0)  //AJAX CALL
}
function pre_load(alpha){
           if($('page_ajax_tracker').value!=alpha && $('page_special').value != 1)return(false)
           else {
                //LOCK LOADING
                $('page_ajax_tracker').value='9999'
                for(count = 1; count <= 5; count++){
                      var add='next_row_'+count
                      if(add=='next_row_1'){
                          var page_init = $('page_init').value
                          if(Number(page_init)==0){
                              $('first_sec').innerHTML = ''
                             // $('first_sec').style.display = 'none'
                          }
                      }
                      $(add).innerHTML = '<div class="browse_row"> <div class= "ajax_loading" align="center" > <img src="images/ajax_processing.gif" /></div></div>'
                     // $(add).style.display = 'none'
                }
                $('next_row_end').innerHTML = '<div class="browse_row"> <div class= "ajax_loading" align="center" ><img src="images/ajax_processing.gif" /></div></div>'
                $('page_ajax_tracker').value =alpha
                $('page_special').value=0
           }
           return(false)
}
//BROWSER FUNTIONS
function  showalpha(json){
         if($('page_ajax_tracker').value!=json.alpha)return(false)
          var row=json.row
          //Initiallises page by setting value for page_init
          if(json.page == -1 || json.page ==0){
                    var page_init = $('page_init').value
                    if(Number(page_init)==0){
                        $('first_sec').innerHTML = ''
                        $('first_sec').style.display = 'none'
                        $('page_init').value='1'
                    }
          }
          if(json.end=='end'){
                if(json.header!=''){
                      $('next_row_1').innerHTML=json.header+$('next_row_1').innerHTML
                }
                for(count = row; count <= 5; count++){
                      var add='next_row_'+count
                      $(add).innerHTML = ''
                      $(add).style.display = 'none'
                }
                $('next_row_end').innerHTML = json.output
                $('next_row_end').style.display=''
                $('page_ajax_tracker').value=0
          }else{
                var add='next_row_'+row
                $(add).innerHTML = json.output
                $(add).style.display=''
                var alpha = json.alpha
                var page =json.page
                var row = json.row
                load_alphabet(alpha,page,row)
          }
          return(false)
}

function showupdate_query(json,genre_id,artist_id){
        if(json.trip==0){
            var genre ='<select id="genre_option" onChange="browse_change()">'+ json.genre+'</select>'
            $('genre_page').innerHTML = genre
            var artist ='<select id="artist_option" onChange="browse_change()">'+json.artist+'</select>'
            $('artist_page').innerHTML=artist;
        }else {
             var artist ='<select id="artist_option" onChange="browse_change()">'+$('artist_option').innerHTML+json.artist+'</select>'
            $('artist_page').innerHTML=artist;
        }
        var trip = Number(json.trip)+1
        if(json.end!='end'){
            update_query(trip,genre_id,artist_id)
        }else $('page_ajax_tracker').value=='0'
}

function get_browse_items_2(alpha,page,row,item){
         $('page_special').value=1
         load_alphabet_2(alpha,page,row,item)
}

function alphabet_Filter_2(Alpha,item) {
//alert($('page_ajax_tracker').value)
             if($('page_ajax_tracker').value=='9999'){
                  return(false)
             }
             $('page_ajax_tracker').value= Alpha
             var cur_col =$('td_'+Alpha)
             var present_col_id = $('alphabet_sel').value
             var td_clicked = 'td_'+Alpha; $('alphabet_sel').value = td_clicked
             $(present_col_id).className = "browse-alphabet-td-normal"
             $(cur_col).className = "browse-alphabet-td-selected"
             $(present_col_id).style.bgcolor= '#FFFFFF'
             $(cur_col).style.bgcolor = "#F0F0F0"
            // $('page_ajax_tracker').value=1
             load_alphabet_2(Alpha,-1,0,item)  //AJAX CALL
}

function  showalpha_2(json){
          if($('page_ajax_tracker').value!=json.alpha)return(false)
          var row=json.row
          if(json.page == -1 || json.page ==0){
                var page_init = $('page_init').value
                if(Number(page_init)==0){
                    $('first_sec').innerHTML = ''
                    $('first_sec').style.display = 'none'
                    $('page_init').value='1'
                }
          }
          if(json.end=='end'){
                if(json.header!=''){
                      $('next_row_1').innerHTML=json.header+$('next_row_1').innerHTML
                }
                for(count = row; count <= 5; count++){
                      var add='next_row_'+count
                      $(add).innerHTML = ''
                      $(add).style.display = 'none'
                }
                $('next_row_end').innerHTML = json.output
                $('next_row_end').style.display=''
                $('page_ajax_tracker').value=0
          }else{
                var add_n='next_row_'+row
                $(add_n).innerHTML = json.output
                $(add_n).style.display=''
                var alpha = json.alpha
                var page =json.page
                var row_new = json.row
                var item = json.item
                load_alphabet_2(alpha,page,row_new,item)
          }
          return(false)
}
function get_header_items(alpha,header_id,page,row){
          $('page_special').value=1
          load_header(alpha,header_id,page,row)
}

function header_Filter(Alpha,header_id) {
         $('page_ajax_tracker').value= Alpha
         var cur_col =$('td_'+Alpha)
         var present_col_id = $('alphabet_sel').value
         var td_clicked = 'td_'+Alpha; $('alphabet_sel').value = td_clicked
         $(present_col_id).className = "browse-alphabet-td-normal"
         $(cur_col).className = "browse-alphabet-td-selected"
         $(present_col_id).style.bgcolor= '#FFFFFF'
         $(cur_col).style.bgcolor = "#F0F0F0"
         load_header(Alpha,header_id,-1,0)  //AJAX CALL
}
function  showheader(json){
          if($('page_ajax_tracker').value!=json.alpha)return(false)
          var row=json.row
          //Initiallises page by setting value for page_init
          if(json.page == -1 || json.page ==0){
                    var page_init = $('page_init').value
                    if(Number(page_init)==0){
                        $('first_sec').innerHTML = ''
                        $('first_sec').style.display = 'none'
                        $('page_init').value='1'
                    }
          }
          if(json.end=='end'){
                if(json.header!=''){
                      $('next_row_1').innerHTML=json.header+$('next_row_1').innerHTML
                }
                for(count = row; count <= 5; count++){
                      var add='next_row_'+count
                      $(add).innerHTML = ''
                      $(add).style.display = 'none'
                }
                $('next_row_end').innerHTML = json.output
                $('next_row_end').style.display=''
                if(json.alpha =='News'){
                    var itemcount = json.page*48+(json.row-1)*8+json.itemcount
                       $('itemcount').value=itemcount
                }
          }else{
                var add='next_row_'+row
                $(add).innerHTML = json.output
                $(add).style.display=''
                var alpha = json.alpha
                var page =json.page
                var row = json.row
                var header_id=json.header_id
                load_header(alpha,header_id,page,row)
          }
          return(false)
}
