﻿function Check(name)
{
    try
    {    
    var list = document.getElementById(name);   
    var chkBox = list.getElementsByTagName("input");
    var count = 0;    
    for(var i=0;i<chkBox.length;i++)
    {
        if(chkBox[i].type == "checkbox" && chkBox[i].checked )
        {
            count++;
        }
    }        
    if(count == 0)
    {   
        alert("You must select atleast one item");
        return false;
    }
    else
    {
        var i = confirm('Are you sure want to delete?');
        if(i==1)
        {
            return true;
        }
        else 
            return false;
    }
    }
    catch(err)
    {
        alert("No item found.");
        return false;
    }        
}

function CheckCheckBox(name)
{
    try
    {    
    var list = document.getElementById(name);   
    var chkBox = list.getElementsByTagName("input");
    var count = 0;    
    for(var i=0;i<chkBox.length;i++)
    {
        if(chkBox[i].type == "checkbox" && chkBox[i].checked )
        {
            count++;
        }
    }        
    if(count == 0)
    {   
        alert("You must select atleast one item");
        return false;
    }
    else
    {       
            return true;
     }      
    }
    catch(err)
    {
        alert("No item found.");
        return false;
    }        
}


function CheckEmpty(id,unsuccess)
{
    var i = document.getElementById(id);
    if(i.value.length == 0)
    {
    alert(unsuccess);
    return false;
    }   
    if(i.value.length <= 4)
    {
    alert('You must enter minimum 4 characters');
    return false;
    }
    return true;
    
}


function AlphaNavigation(name,id){
var az = new Array('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z');
var p,s;

for (var i=0; i<=25; i++) {
if(az[i]==id){
s=i;}
p=name.concat(az[i]);

document.getElementById(p).className='ss3';
}
p=name.concat(az[s]);
document.getElementById(p).className='ss3a';
}

function CheckAlbum(name)
{
    var list = document.getElementById(name);   
    var chkBox = list.getElementsByTagName("input");   
    var count = 0;    
    for(var i=0;i<chkBox.length;i++)
    {
        if(chkBox[i].type == "checkbox" && chkBox[i].checked )
        {
            ++count;
        }
    }        
    
    if(count == 0)
    {   
        alert("You must select atleast one item");
        return false;
    }
    else if(count == 1)
    {
        return true;
    }        
    else if(count >=2)
    {
        alert("You should select only one item");
        return false;
    }
}
function CheckRadioButton(name)
{
    try
    {
        var list = document.getElementById(name);               
        var radio = list.getElementsByTagName("input");                 
        var isCheck = false;        
        for(var i=0;i<radio.length;i++)
        {
            if(radio[i].type == "radio" && radio[i].checked )
            {
                isCheck = true;
            }
        }                
        if(isCheck)
        {           
            return true;
        }
        else
        {
            alert("You must select atleast one item");
            return false;
        }
     }        
     catch(err)
     {         
        alert("No item found.");
        return false;                 
     }
}
function Confirm(message)
{
    var i = confirm(message);
    if(i==1)
    return true;
    else  
    return false;
}
function QueryString1()
{
    var hu = window.location.search.substring(1);    
    var i = hu.split("=");    
    if(i[0]=="q")
    {       
        return i[1];
    }
}
function QueryString()
{
    var hu = window.location.search.substring(1);     
    var i = hu.split("&");       
    var j = i[0].split("=");
    if(j[0]=="cat")
    {       
        return j[1];
    }
}
    function getFileName(path){

    var fn = path.match(/\/([a-z0-9_-]+\.\w+)/i);
    return (fn == null)? "" : fn[1];

    }
    function formatText(el,tagstart,tagend) {
        
        if (el.setSelectionRange) {
 	    	el.value = el.value.substring(0,el.selectionStart) + tagstart + el.value.substring(el.selectionStart,el.selectionEnd) + tagend + el.value.substring(el.selectionEnd,el.value.length)
  	    }
  	    else
  	    {
            var selectedText = document.selection.createRange().text;        
            if (selectedText != "") {
            var newText = tagstart + selectedText + tagend;
            document.selection.createRange().text = newText;
            }
        }
    }
    function HyperlinkText(el) {
        var txt = prompt("Enter the website link","http://");
        if (el.setSelectionRange) {
 	    	el.value = el.value.substring(0,el.selectionStart) + "<a href='" + txt + "'>" + el.value.substring(el.selectionStart,el.selectionEnd) + "</a>" + el.value.substring(el.selectionEnd,el.value.length)
  	    }
  	    else
  	    {
            var selectedText = document.selection.createRange().text;
        
            if (selectedText != "") {
                var newText = "<a href='" + txt + "'>" + selectedText + "</a>";
                document.selection.createRange().text = newText;
            }
        }
    }
   
    function doClick(buttonName,e)
    {
//the purpose of this function is to allow the enter key to 

//point to the correct button to click.

        var key;

         if(window.event)
              key = window.event.keyCode;     //IE

         else
              key = e.which;     //firefox
    
        if (key == 13)
        {
            //Get the button the user wants to have clicked

            var btn = document.getElementById(buttonName);
            if (btn != null)
            { //If we find the button click it

                btn.click();
                event.keyCode = 0
            }
        }
   }


// Keep user from entering more than maxLength characters

function doKeypress(control){
    maxLength = control.attributes["maxLength"].value;
    value = control.value;
     if(maxLength && value.length > maxLength-1){
          event.returnValue = false;
          maxLength = parseInt(maxLength);
     }    
}
// Cancel default behavior

function doBeforePaste(control){
    maxLength = control.attributes["maxLength"].value;
     if(maxLength)
     {
          event.returnValue = false;
     }
}
// Cancel default behavior and create a new paste routine

function doPaste(control){
    maxLength = control.attributes["maxLength"].value;
    value = control.value;
     if(maxLength){
          event.returnValue = false;
          maxLength = parseInt(maxLength);
          var oTR = control.document.selection.createRange();
          var iInsertLength = maxLength - value.length + oTR.text.length;
          var sData = window.clipboardData.getData("Text").substr(0,iInsertLength);
          oTR.text = sData;
     }
}



function changeVideo(swf,displaythis){
	var w=500;
	var h=390;
swf="http://www.youtube.com/v/" + swf + "&color1=0xb1b1b1&color2=0xcfcfcf&feature=player_embedded&fs=1";
var filedisplay;
filedisplay='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" id="main01" width="'+w+'" height="'+h+'">' + '<param name="movie" value="'+swf+'"/>' + '<param name="quality" value="high"/>' + '<param name="allowFullScreen" value="true"/>' + '<param name="base" value="true"/>' + '<param name="loop" value="true"/>' +'<param name="wmode" value="transparent"/>' + '<embed type="application/x-shockwave-flash"  allowfullscreen="true" src="'+swf+'" width="'+w+'" height="'+h+'"></embed>' + '</object>';

document.getElementById("videodiv").innerHTML=filedisplay;
document.getElementById("videodesc").innerHTML=displaythis;
}
function changeVideo2(swf,displaythis,w,h){
swf="http://www.youtube.com/v/" + swf + "&color1=0xb1b1b1&color2=0xcfcfcf&feature=player_embedded&fs=1";
var filedisplay;
filedisplay='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" id="main01" width="'+w+'" height="'+h+'">' + '<param name="movie" value="'+swf+'"/>' + '<param name="quality" value="high"/>' + '<param name="allowFullScreen" value="true"/>' + '<param name="base" value="true"/>' + '<param name="loop" value="true"/>' +'<param name="wmode" value="transparent"/>' + '<embed type="application/x-shockwave-flash"  allowfullscreen="true" src="'+swf+'" width="'+w+'" height="'+h+'"></embed>' + '</object>';

document.getElementById("videodiv").innerHTML=filedisplay;
document.getElementById("videodesc").innerHTML=displaythis;
}
function SideVideo(swf){
var w=290;
var h=230;
swf="http://www.youtube.com/v/" + swf + "&color1=0xb1b1b1&color2=0xcfcfcf&feature=player_embedded&fs=1";
var filedisplay;
filedisplay='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" id="main01" width="'+w+'" height="'+h+'">' + '<param name="movie" value="'+swf+'"/>' + '<param name="quality" value="high"/>' + '<param name="allowFullScreen" value="true"/>' + '<param name="base" value="true"/>' + '<param name="loop" value="true"/>' +'<param name="wmode" value="transparent"/>' + '<embed type="application/x-shockwave-flash" allowfullscreen="true" src="'+swf+'" width="'+w+'" height="'+h+'"></embed>' + '</object>';
document.getElementById("videodiv2").innerHTML=filedisplay;
}
