﻿function makePOSTRequest(url, parameters,type) 
{
    http_request = false;
    if (window.XMLHttpRequest) 
    { // Mozilla, Safari,...
        http_request = new XMLHttpRequest();
        if (http_request.overrideMimeType) 
        {
            // set type accordingly to anticipated content type
            http_request.overrideMimeType('text/html');
        }
    } 
    else if (window.ActiveXObject) 
    { // IE
        try 
        {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
        } 
        catch (e) 
        {
            try 
            {
                http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } 
            catch (e) 
            {
            }
        }
    }
    if (!http_request) {
        alert('Cannot create XMLHTTP instance');
        return false;
    }
    if(type=="1") http_request.onreadystatechange = DeleteImage;

    http_request.open('POST', url, true);
    http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    http_request.setRequestHeader("Content-length", parameters.length);
    http_request.setRequestHeader("Connection", "close");
    http_request.send(parameters);
}

function DeleteImage()
{
    if (http_request.readyState == 4)
    {
        if (http_request.status == 200)
        {
            result = http_request.responseText;
            alert(result);
            window.location='http://localhost/admin/imagerepository.aspx';
        }
        else alert('There was problem with request.');
    }
}
function DelImage(ImageName,ImgID)
{
    ImageName=replaceAll(ImageName,'/','*');

    if (confirm('Are you sure, you want to delete this image?'))
    {
        var param = "imgName="+ ImageName + "&ImgID=" + ImgID;
        makePOSTRequest('DeleteImage.aspx',param,"1");
    }
}

function updateImgDetails(ImgID,Desc)
{
    alert(Desc);
}
function replaceAll(text, strA, strB)
{
    while ( text.indexOf(strA) != -1)
    {
        text = text.replace(strA,strB);
    }
    return text;
}

function ShowUpdateLayer(ImageId, ImageDesc)
{
    getPageSize(1);
    document.getElementById("divUpdate").style.display='block';
    document.getElementById("txtImageDescription").value=ImageDesc;
    document.getElementById("hdnImageID").value=ImageId;
    document.getElementById("fade").style.display='block';
}
function ShowPage(type)
{
    if(type == 'U')
    {
        document.getElementById("divUpdate").style.display='none';
    }
    else if(type == 'A')
    {
        document.getElementById("divAdd").style.display='none';
    }
    else if(type == 'AF')
    {
        document.getElementById("divADDFolder").style.display='none';
    }
    else if(type == 'DF')
    {
        document.getElementById("divDeleteFolder").style.display='none';
    }
    else if(type == 'M')
    {
        document.getElementById("divMove").style.display='none';
    }
    else if(type == 'C')
    {
        document.getElementById("divCopy").style.display='none';
    }
    document.getElementById("fade").style.display='none';
}

function ShowLayer(type)
{
    getPageSize(1);
   if(type == 'U')
    {
    getCheckList();
        document.getElementById("divUpdate").style.display='block';
    }
    else if(type == 'A')
    {
    getCheckList();
        document.getElementById("divAdd").style.display='block';
        document.getElementById("Text2").value= document.getElementById("hdnFolderName").value;
    }
     else if(type == 'AF')
    {
        document.getElementById("divADDFolder").style.display='block';
        document.getElementById("divFolderPath").innerHTML = document.getElementById("hdnFolderName").value;
    }
     else if(type == 'DF')
    {
        document.getElementById("divDeleteFolder").style.display='block';
        //document.getElementById("Text4").value = document.getElementById("hdnFolderName").value;
    }
    else if(type == 'M')
    {
    getCheckList();
        if(document.getElementById('hdnCheckList').value!="")
         document.getElementById("divMove").style.display='block';
    }
    else if(type == 'C')
    {    
    getCheckList();
    if(document.getElementById('hdnCheckList').value!="")
        document.getElementById("divCopy").style.display='block';
    }
    document.getElementById("fade").style.display='block';
}

function getPageSize(i)
{
    var xScroll, yScroll;

	if (window.innerHeight && window.scrollMaxY) {	

		xScroll = document.body.scrollWidth;

		yScroll = window.innerHeight + window.scrollMaxY;

	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac

		xScroll = document.body.scrollWidth;

		yScroll = document.body.scrollHeight;

	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari

		xScroll = document.body.offsetWidth;

		yScroll = document.body.offsetHeight;

	}

	var windowWidth, windowHeight;

	if (self.innerHeight) {	// all except Explorer

		windowWidth = self.innerWidth;

		windowHeight = self.innerHeight;

	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode

		windowWidth = document.documentElement.clientWidth;

		windowHeight = document.documentElement.clientHeight;

	} else if (document.body) { // other Explorers

		windowWidth = document.body.clientWidth;

		windowHeight = document.body.clientHeight;

	}	
	
	// for small pages with total height less then height of the viewport

	if(yScroll < windowHeight){

		pageHeight = windowHeight;

	} else { 


		pageHeight = yScroll;

	}



	// for small pages with total width less then width of the viewport

	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}

    var paghg;
    paghg =  windowHeight + yScroll;

	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 

    if(navigator.userAgent.indexOf("Firefox")!=-1)
    {   pageWidth = pageWidth - 17;  }
    
    if(i == 1)
    {
        document.getElementById('fade').style.width = (pageWidth + 'px');
        document.getElementById('fade').style.height =  (pageHeight + 'px');
    }
}
function trim(str) //Ths trims the input texts
{
    var str1=str.replace(/\S/g,"|");
    var i=str1.indexOf("|")-1;
    var j=str1.lastIndexOf("|")+1;
    var trimStr=str.substring(0,i).replace(/\s/g,"") + str.substring(i+1,j);
    trimStr = trimStr + str.substring(j).replace(/\s/g,"");
    return trimStr; 
}

function DeleteMultipleImages()
{       
    var cbResults = '';
    for (var i = 0; i < document.forms.Link_form.elements.length; i++ ) 
    {
        if (document.forms.Link_form.elements[i].type == 'checkbox') 
        {
            if (document.forms.Link_form.elements[i].checked == true) 
            {
                cbResults += document.forms.Link_form.elements[i].value + ' ';
            }
        }
    }
    if (cbResults =='')
    {
        alert('Please select an image to delete.');
        return false;
    }
    cbResults=replaceAll(trim(cbResults),' ','-');

    if (confirm('Are you sure, you want to delete this image?'))
    {
        var param = "ImageIDs="+ cbResults ;
        makePOSTRequest('DeleteImage.aspx',param,"1");
    }
}

function getCheckList()
{
 var cbResults = '';
    for (var i = 0; i < document.forms.Link_form.elements.length; i++ ) 
    {
        if (document.forms.Link_form.elements[i].type == 'checkbox') 
        {
            if (document.forms.Link_form.elements[i].checked == true) 
            {
                cbResults += document.forms.Link_form.elements[i].value + ',';
            }
        }
    }
    //cbResults=replaceAll(trim(cbResults),' ',',');
    if(cbResults=="")
    {
        //alert('Please select an image');
       
    }
    document.getElementById('hdnCheckList').value=cbResults;
}
function ShowHeaderlayer()
{
    getPageSize(1);
    document.getElementById("jsWrapper_HeaderText").style.display='block';
    document.getElementById("fade").style.display='block'
    return false;
}

/******************************Added By Salim*******************************/

function showContentLayer(contentitemid)
{
getPageSize(1);
    if(contentitemid == 1)
    {
        document.getElementById("jsWrapper_Text").style.display='block';
        alertSize();
        document.getElementById('jsWrapper_Text').style.left=(parseInt(myWidth/2) - 285) + "px";
    } 
    else if(contentitemid == 2)
    {
        document.getElementById("jsWrapper_Image").style.display='block';
        alertSize();
        document.getElementById('jsWrapper_Image').style.left=(parseInt(myWidth/2) - 285) + "px";
    } 
    else if(contentitemid == 3)
    {
        document.getElementById("jsWrapper_ImageText").style.display='block';
        alertSize();
        document.getElementById('jsWrapper_ImageText').style.left=(parseInt(myWidth/2) - 285) + "px";
    }     
    else if(contentitemid == 4)
    {
        document.getElementById("jsWrapper_Flash").style.display='block';
        alertSize();
        document.getElementById('jsWrapper_Flash').style.left=(parseInt(myWidth/2) - 285) + "px";
    }
    else if(contentitemid == 5)
    {
        document.getElementById("jsWrapper_Table").style.display='block';
        document.getElementById("btnSubmit").style.display='none';
        alertSize();
        document.getElementById('jsWrapper_Table').style.left=(parseInt(myWidth/2) - 285) + "px";
    }
    else if(contentitemid == 6)
    {
        document.getElementById("jsWrapper_TextLink").style.display='block';
        alertSize();
        document.getElementById('jsWrapper_TextLink').style.left=(parseInt(myWidth/2) - 285) + "px";
    }
    else if(contentitemid == 7)
    {
        document.getElementById("jsWrapper_HeaderText").style.display='block';
        alertSize();
        document.getElementById('jsWrapper_HeaderText').style.left=(parseInt(myWidth/2) - 285) + "px";
    }
     else if(contentitemid == 8)
    {
        if(document.getElementById(id_m +"hdn_Exist_rec").value=="")
            document.getElementById("frmSubmit").style.display='none';
        else
            document.getElementById("frmSubmit").style.display='block';
        document.getElementById("jsWrapper_Form").style.display='block';
        alertSize();
        document.getElementById('jsWrapper_Form').style.left=(parseInt(myWidth/2) - 350) + "px";
    }
    else if(contentitemid == 11)
    {
        document.getElementById("jsWrapper_FileUploader").style.display='block';
        alertSize();
        document.getElementById('jsWrapper_FileUploader').style.left=(parseInt(myWidth/2) - 285) + "px";
    }  
    else if(contentitemid == 12)
    {
        document.getElementById("jsWrapper_ProgrClips").style.display='block';
        alertSize();
        document.getElementById('jsWrapper_ProgrClips').style.left=(parseInt(myWidth/2) - 285) + "px";
    }    
     else if(contentitemid == 13)
    {
        document.getElementById("jsWrapper_RecProd").style.display='block';
        alertSize();
        document.getElementById('jsWrapper_RecProd').style.left=(parseInt(myWidth/2) - 285) + "px";
    }      
    else if(contentitemid == 14)
    {
        document.getElementById("jsWrapper_History").style.display='block';
        alertSize();
        document.getElementById('jsWrapper_History').style.left=(parseInt(myWidth/2) - 285) + "px";
    }
    else if(contentitemid == 15)
    {
        document.getElementById("jsWrapper_ReleaseLink").style.display='block';
        alertSize();
        document.getElementById('jsWrapper_ReleaseLink').style.left=(parseInt(myWidth/2) - 285) + "px";
    }   
     else if(contentitemid == 16)
    {
        document.getElementById("jsWrapper_HeadlineImageText").style.display='block';
        alertSize();
        document.getElementById('jsWrapper_HeadlineImageText').style.left=(parseInt(myWidth/2) - 285) + "px";
    }                      
    document.getElementById("fade").style.display='block'
    return false;
}
var myWidth = 0, myHeight = 0;
function alertSize()
 {
  if( typeof( window.innerWidth ) == 'number' ) 
  {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
}

function hideContentLayer(contentitemid)
{
    if(contentitemid == 1)
    {
        document.getElementById("jsWrapper_Text").style.display='none';
    }
    else if(contentitemid == 2)
    {
        document.getElementById("jsWrapper_Image").style.display='none';
    } 
    else if(contentitemid == 3)
    {
        document.getElementById("jsWrapper_ImageText").style.display='none';
    } 
    else if(contentitemid == 4)
    {
        document.getElementById("jsWrapper_Flash").style.display='none';
    }
    else if(contentitemid == 5)
    {
        document.getElementById("jsWrapper_Table").style.display='none';
    }
    else if(contentitemid == 6)
    {
        document.getElementById("jsWrapper_TextLink").style.display='none';
    }
    else if(contentitemid == 7)
    {
        
        document.getElementById("jsWrapper_HeaderText").style.display='none';
        //document.getElementById('ctl00_ht_txtContentName').value = "";
        document.getElementById('ctl00_ht_txtContentDescription').value= "";
                var inst = FCKeditorAPI.GetInstance("ctl00_ht_txtHead");  
                var str = "";             
                inst.SetHTML(str);
                var inst1 = FCKeditorAPI.GetInstance("ctl00_ht_txtText");               
                inst1.SetHTML(str);
                document.getElementById('ctl00_ht_txtOrderNumber').value = "";
                document.getElementById('ctl00_hdn_contentitem_id').value = "";
    }
    else if(contentitemid == 8)
    {
        document.getElementById("jsWrapper_Form").style.display='none';
    }
    else if(contentitemid == 11)
    {
        document.getElementById("jsWrapper_FileUploader").style.display='none';
    }
     else if(contentitemid == 12)
    {
        document.getElementById("jsWrapper_ProgrClips").style.display='none';
    }
    else if(contentitemid == 13)
    {
        document.getElementById("jsWrapper_RecProd").style.display='none';
    }
    else if(contentitemid == 14)
    {
        document.getElementById("jsWrapper_History").style.display='none';
    }
    else if(contentitemid == 15)
    {
        document.getElementById("jsWrapper_ReleaseLink").style.display='none';
    }
     else if(contentitemid == 16)
    {
        document.getElementById("jsWrapper_HeadlineImageText").style.display='none';
    }
        document.getElementById("fade").style.display='none'
}

function validateHeaderText()
{
    return true;
//    var EditorInstance = FCKeditorAPI.GetInstance('ctl00_ht_txtHead') ;
//    if((EditorInstance.EditorDocument.body.innerHTML == "<br>") || (EditorInstance.EditorDocument.body.innerHTML == "") || (document.getElementById("ctl00_ht_txtContentName").value == "") || (document.getElementById("ctl00_ht_txtContentDescription").value == "") || (document.getElementById("ctl00_ht_txtOrderNumber").value == ""))
//    {
//        alert("All * fields are mandatory");
//        return false;
//    }
}

function GetName()
{
    LUploadFile.FileName=opener.document.Link_form.ImgName.value;
    return false;
} 
//function GetLink()
//{           
//   window.open("LinkAdd.aspx",'','left=0, top=0, width=600,height=500');
//   return false;
//}
function GetImageLink_FU(filename,filelogo,filesize)
{           
   window.open("Files.aspx?fileName="+filename+"&filelogo="+filelogo+"&filesize="+filesize+"",'','left=0, top=0, width=900,height=750,scrollbars=1')
}
// function GetImageLink(param)
//{           
//   window.open("Images.aspx?txtname="+param,'','left=0, top=0, width=900,height=750,scrollbars=1');
//   return false;
//}
function imagelinks(a)
{
   var imgrecognise = a;
   window.open("imageadd.aspx?id="+ imgrecognise +"",'','left=0, top=0, width=350,height=300');
   return false;
}
function File_Name()
{
   opener.document.form1.txtLink.value = document.SubmitLink.cross_product.value
   document.getElementById(ImgName).value=opener.document.form1.LUploadFile.FileName
}
function add_rec(txtname)
{         
    opener.document.getElementById(txtname).value = document.getElementById("image").value; 
    window.close();        
}
function click_image(imagepath,imgid)
{  
    var previd;
    previd = document.getElementById("imgid").value;
    if(previd != "")
        document.getElementById(previd).style.border = "1px solid #ffffff";
    document.getElementById("image").value=imagepath;
    document.getElementById("imgid").value=imgid;
    document.getElementById(imgid).style.border = "1px solid red";
}
function validateText()
{
    var EditorInstance = FCKeditorAPI.GetInstance('ctl00_t_txtText') ;
    if((EditorInstance.EditorDocument.body.innerHTML == "<br>") || (EditorInstance.EditorDocument.body.innerHTML == "") || (document.getElementById("ctl00_t_txtContentName").value == "") || (document.getElementById("ctl00_t_txtContentDescription").value == "") || (document.getElementById("ctl00_t_txtOrderNumber").value == ""))
    {
        alert("All * fields are mandatory");
        return false;
    }
}
function validateImage()
{
    if((document.getElementById("ctl00_i_txtContentName").value == "") || (document.getElementById("ctl00_i_txtContentDescription").value == "") || (document.getElementById("ctl00_i_txtAltText").value == "") || (document.getElementById("ctl00_i_txtLink").value == "") || (document.getElementById("ctl00_i_txtfilename").value == "") || (document.getElementById("ctl00_i_txtOrderNumber").value == ""))
    {
        alert("All * fields are mandatory");
        return false;
    }
}
function validateImageText()
{
    var EditorInstance = FCKeditorAPI.GetInstance('ctl00_it_txtText') ;
    if((EditorInstance.EditorDocument.body.innerHTML == "<br>") || (EditorInstance.EditorDocument.body.innerHTML == "") || (document.getElementById("ctl00_it_txtContentName").value == "") || (document.getElementById("ctl00_it_txtContentDescription").value == "") || (document.getElementById("ctl00_it_txtAltText").value == "") || (document.getElementById("ctl00_it_txtLink").value == "") || (document.getElementById("ctl00_it_txtfilename").value == "") || (document.getElementById("ctl00_it_txtOrderNumber").value == ""))
    {
        alert("All * fields are mandatory");
        return false;
    }
}
function validateFileUploader()
{
    if((document.getElementById("ctl00_fu_contentname").value == "") || (document.getElementById("ctl00_fu_contentdesc").value == "") || (document.getElementById("ctl00_fu_filename").value == "") || (document.getElementById("ctl00_fu_orderno").value == ""))
    {
        alert("All * fields are mandatory");
        return false;
    }
}

function validateTextLink()
{
    if((document.getElementById("ctl00_tl_contentname").value == "") || (document.getElementById("ctl00_tl_contentdesc").value == "") || (document.getElementById("ctl00_tl_text").value == "") || (document.getElementById("ctl00_tl_link").value == "") || (document.getElementById("ctl00_tl_orderno").value == ""))
    {
        alert("All * fields are mandatory");
        return false;
    }
}

function validateFlash()
{
    if((document.getElementById("ctl00_fl_contentname").value == "") || (document.getElementById("ctl00_fl_contentdesc").value == "") || (document.getElementById("ctl00_fl_filename").value == "") || (document.getElementById("ctl00_fl_objectid").value == "") || (document.getElementById("ctl00_fl_height").value == "") || (document.getElementById("ctl00_fl_width").value == "") || (document.getElementById("ctl00_fl_orderno").value == ""))
    {
        alert("All * fields are mandatory");
        return false;
    }
}
/********************************** Hiren *****************************************/
function validateTable()
{
    var bindString = '';
    if((document.getElementById("ctl00_tb_Contentname").value == "") || (document.getElementById("ctl00_tb_ContentDesc").value == "") || (document.getElementById("ctl00_tb_Columns").value == "") || (document.getElementById("ctl00_tb_Order").value == ""))
    {
        alert("All * fields are mandatory");
        return false;
    }
    else if(isNaN(document.getElementById("ctl00_tb_Columns").value))
    {
        alert("Please enter only numeric value in Number of Columns");
        return false;
    }
    else if(isNaN(document.getElementById("ctl00_tb_Order").value))
    {
        alert("Please enter only numeric value in Orderno");
        return false;
    }
    else
    {
        var Column = document.getElementById("ctl00_tb_Columns").value;
        var Header = document.getElementById("ctl00_chk_Header").checked;
        
        if(Header == true)
        {
            bindString = "<div class=\"pg_1 frmLabel float_left padding_left15\"><span class=\"AlignLeft\">Heading Data</span>";
            bindString += "<table class=\"padding_top10\">";
            for(var i = 1; i <= Column; i++)
            {
                bindString += "<td><input class=\"centeralign\" type=\"text\" id=\"H1_" + i + "\" name=\"H1_" + i + "\"  value=\"\"/></td>";
            }
            bindString += "</table>";
            bindString += "</div>";
        }
        document.getElementById("genHeadTable").innerHTML = bindString;
        document.getElementById("ctl00_hidcol").value = Column;
        document.getElementById("ctl00_hidrow").value = 1;
        bindString = '';
        bindString = "<div class=\"float_left\"><span class=\"AlignLeft tbText\">Data</span>";
        bindString += "<table><tr><td><input type=\"button\" name=\"del_1\" value=\"&#45;\" id=\"del_1\" onclick=\"javascript:return addDelRow('del',1)\" style=\"width:20px;\"/></td>";
        for(var j = 1; j <= Column; j++)
        {
           bindString += "<td><input class=\"centeralign\" type=\"text\" id=\"R1_" + j + "\" name=\"R1_" + j + "\" value=\"\"/></td>";
        }
        bindString += "<td><input type=\"button\" name=\"add_1\" value=\"&#43;\" id=\"add_1\" onclick=\"javascript:return addDelRow('add',1)\" style=\"width:20px;\"/></td>";
        bindString += "</tr></table>";
        bindString += "</div>";
        document.getElementById("genRowTable").innerHTML = bindString;
        document.getElementById("btnSubmit").style.display='block';
    }
}

function addDelRow(mode,rowid)
{	
	var str;
	var inputvalue_desc;
	str = '';
	rowcnt = document.getElementById("ctl00_hidrow").value;
	if(mode == 'del')
	{
	    if(rowcnt == 1)
	    {
	        alert("This operation cannot be performed");
	        return false;
	    }
	} 
	else 
	{
	    rowcnt = parseInt(rowcnt)  + 1;    
	}
	
	colcount = document.getElementById("ctl00_hidcol").value;
	
	str = str + "<div class=\"float_left\"><span class=\"AlignLeft tbText\">Data</span>";
	str = str + '<table>';
	for(rownum = 1;rownum <= rowcnt; rownum++)
	{   
	    r_name = rownum;
	    if(mode == 'del')
	    {
	        if(rownum == rowid) continue;
	        if(rownum > rowid) r_name = parseInt(r_name) - 1;
	    }
	    
		str = str + '<tr id=\'Row_' + rownum + '\' >';
		str = str + '<td><input type=\"button\" style=\"width:20px;\" id=\"del_' + rownum + '\' name=\"del_' + rownum + '\' value=\'&#45;\' onclick=\"addDelRow(\'del\',' + r_name + ')\"></td>';
		for(colcnt = 1; colcnt <= colcount; colcnt++)
		{   
		    if (document.getElementById("R" + rownum + "_" + colcnt))
			    inputvalue_desc = document.getElementById("R" + rownum + "_" + colcnt).value;
		    else
			    inputvalue_desc = '';
			str = str + '<td><input class=\'centeralign\' type=\'text\' id=\'R' + r_name +  '_' + colcnt + '\' name=\'R' + r_name +  '_' + colcnt + '\'  value=\'' + inputvalue_desc +  '\'></td>';
		}
		str = str + '<td><input type=\"button\" style=\"width:20px;\" id=\"del_' + rownum + '\ name=\"add_' + r_name + '\' value=\'&#43;\' onclick=\"addDelRow(\'add\',0)\"></td>';
		str = str + '</tr>';
	}
    if(mode == 'del') rowcnt = parseInt(rowcnt) - 1;
    
    document.getElementById("ctl00_hidrow").value = rowcnt;
    document.getElementById("ctl00_hfrow").value = rowcnt;
	str = str + '</table></div>';
	
	document.getElementById('genRowTable').innerHTML = ''
	document.getElementById('genRowTable').innerHTML = str;
}


/********************************** Hiren *****************************************/

function validateHistory()
{
    var Error="Please enter value of these following fields";
    var EditorInstance = FCKeditorAPI.GetInstance('ctl00_histoy_desc');     //  'ctl00_txtText’ is the ID of FCKEditor
    if(document.getElementById("ctl00_history_cnt_name").value == "")
    {
       Error=Error+"\nContentName";        
    }
    if(document.getElementById("ctl00_history_cnt_Desc").value == "")
    {
       Error=Error+"\nContent Description";        
    }
     if(document.getElementById("ctl00_history_filename").value == "")
    {
       Error=Error+"\nFileName";       
    }
     if(document.getElementById("ctl00_history_alttxt").value == "")
    {
       Error=Error+"\nAlternet Text";       
    }
     if(document.getElementById("ctl00_history_year").value == "")
    {
       Error=Error+"\nYear";       
    }
    if(EditorInstance.EditorDocument.body.innerHTML == "<br>")    
    {
       Error=Error+"\nDescription";       
    }
    if(Error!="Please enter value of these following fields")
    {
    alert(Error);
    return false;
    }   
    
}

function validateForm()
{
    if((document.getElementById("ctl00_fmContent").value == "") || (document.getElementById("ctl00_fmContentDesc").value == "") || (document.getElementById("ctl00_fmEmailAdd").value == ""))
    {
        alert("All * fields are mandatory");
        return;
    }
}
function AddFormData(k)
{
    var fillFromData = '';
    fillFromData = fillFromData + "<div id=\"row_"+k+"\" class=\"frmInputData1\">";
    fillFromData = fillFromData + "<div class=\"float_left\"><img id=\"add\" src=\"../images/-.gif\" title=\"Add More\" onclick=\"javascript:DelFormData('"+k+"');\"></div>";
    fillFromData = fillFromData + "<div class=\"float_left padding_left10\"><select runat=\"server\" id=\"Select_type"+k+"\" name=\"Select_type"+k+"\" title=\"Type\"><option id=\"chtype_"+k+"\">CheckBox</option><option id=\"ddtype_"+k+"\">DropDown</option><option id=\"rbtype_"+k+"\">Radio Button</option><option id=\"tatype_"+k+"\">TextArea</option><option id=\"txtype_"+k+"\">TextBox</option></select></div>";
    fillFromData = fillFromData + "<div class=\"float_left padding_left5\"><input id=\"FName"+k+"\" name=\"FName"+k+"\" type=\"text\" value=\"\" runat=\"server\" title=\"Name\" class=\"width120\" /></div>";
    fillFromData = fillFromData + "<div class=\"float_left padding_left5\"><input id=\"FData"+k+"\" name=\"FData"+k+"\" type=\"text\" value=\"\" runat=\"server\" title=\"Data\" class=\"width120\" /></div>";
    fillFromData = fillFromData + "<div class=\"float_left padding_left45\"><input id=\"FChk"+k+"\" name=\"FChk"+k+"\" type=\"checkbox\" value=\"\" runat=\"server\" title=\"Is Mandatory\" /></div>";
    fillFromData = fillFromData + "<div class=\"float_left padding_left40\"><input id=\"Order"+k+"\" name=\"Order"+k+"\" type=\"text\" value=\"\" runat=\"server\" title=\"OrderNo\" class=\"width30\" /></div>";
    k++;
    fillFromData = fillFromData + "<div class=\"float_left padding_left20\"><img id=\"add\" src=\"../images/+.gif\" title=\"Add More\" onclick=\"javascript:AddFormData("+ k +");\"></div>";
    fillFromData = fillFromData + "</div>";
     
    document.getElementById('bindFormData').innerHTML = fillFromData;
}


/******************************* Start Script for Recent Productions *****************************/

function getChannels(c_id)
{   
    window.open("Add_channles.aspx?c_id="+c_id+"",'','left=180, top=300, width=650,height=150');
}
function GetLinks(txtBoxName)
{
    window.open("Linkadd.aspx?txtBoxName="+txtBoxName+"",'','left=0, top=0, width=600,height=500')
}
function GetImageLink(txtName)
{           
    window.open("Images.aspx?txtBoxName="+txtName+"",'','left=0, top=0, width=900,height=900,scrollbars=yes')
}

function validateRec_Prod()
{
    if(document.getElementById("ctl00_txtProdName").value == "" || document.getElementById("ctl00_txtProdDesc").value == "" ||document.getElementById("ctl00_txtProdAltText").value == "" || document.getElementById("ctl00_txtfilename").value == ""  || document.getElementById("ctl00_txtProdOrder").value == ""  )
    {
        alert("All * fields are mandatory");
        return false;
    }
}

/******************************* End Script for Recent Productions *****************************/


/*********Added By Arti*********/


function GetChannelImageLink(txtName)
{           
    window.open("Images.aspx?txtBoxName="+txtName+"",'','left=0, top=0, width=900,height=900,scrollbars=yes')
}

function validateHeadlineImageText()
{
    if((document.getElementById("ctl00_hit_txtContentName").value == "") || (document.getElementById("ctl00_hit_txtOrderNumber").value == "") )
    {
        alert("All * fields are mandatory");
        return false;
    }
}

function validateReleaseLink()
{
    var Error="Please enter value of these following fields";
    if(document.getElementById("ctl00_r_txtContentName").value == "")
    {
       Error=Error+"\nContentName";        
    }
    if(document.getElementById("ctl00_r_txtContentDescription").value == "")
    {
       Error=Error+"\nContent Description";        
    }
     if(document.getElementById("ctl00_r_txtText").value == "")
    {
       Error=Error+"\nText";       
    }
     if(document.getElementById("ctl00_r_txtfilepath").value == "")
    {
       Error=Error+"\nLink";       
    }
     if(document.getElementById("ctl00_r_txtcalender").value == "")
    {
       Error=Error+"\nDate";       
    }
     if(document.getElementById("ctl00_r_txtOrderNumber").value == "")
    {
       Error=Error+"\nOrder Number";       
    }
    if(Error!="Please enter value of these following fields")
    {
    alert(Error);
    return false;
    }   
    
}


/*****End By Arti****/

/********** Added By Hiren ******/
function Clickheretoprint(Print_Text)
{   
    var disp_setting="toolbar=no,location=no,directories=no,menubar=no,"; 
      disp_setting+="scrollbars=yes,width=650, height=600, left=100, top=25"; 
  var content_vlue = Print_Text.replace("%20"," ");
  
  var docprint=window.open("","",disp_setting);
   docprint.document.open(); 
   docprint.document.write('<html><head><title>Biography</title>'); 
   docprint.document.write('</head><body onLoad="self.print()"><center>');          
   docprint.document.write(content_vlue);          
   docprint.document.write('</center></body></html>'); 
   docprint.document.close(); 
   docprint.focus(); 
}
/*********** End By Hiren **************/


/***********Added By Arti for admin layer ************/

function IframeSrc_Data(Control,CN,Id,Hid,Cid,OrderNo)
{   

    //document.getElementById('MasterFrame').src = "";
    var page = window.location.href.split('/');
    var pagename = page[page.length -1];
    var temp;
    if(Cid != '')
    {   
        temp = Control + '.aspx?CN=' + CN + '&id=' + Id +'&dispID=' + Hid + '&cid=' + Cid + '&redi=' + pagename;
    }
    else
    {   
        temp = Control + '.aspx?CN=' + CN + '&id=' + Id + '&dispID=' + Hid + '&OrderNo=' + OrderNo + '&redi=' + pagename;
    }
    
    document.getElementById("divright").style.display='block';
    //document.getElementById("MasterFrame").style.display='block';
    document.getElementById("text_div").style.display='none';
       document.getElementById("text_default").style.display='none';
    document.getElementById('newIFrame').innerHTML = "<iframe id=\"MasterFrame\" src=\""+temp+"\" width=\"585\" height=\"750\" scrolling=\"no\" class=\"float_left\" frameborder=\"0\"></iframe>";
    //getPageSize(1);
    //document.getElementById("fade").style.display='block';
    return false;    
}

function toggleAlert() 
{
    toggleDisabled(document.getElementById("ctl00_ContentPlaceHolder1_HDR"));
}
function toggleDisabled(el) {
    try 
    {
        el.disabled = el.disabled ? false : true;
    }
    catch(E)
    {
    }
    if (el.childNodes && el.childNodes.length > 0) 
    {
        for (var x = 0; x < el.childNodes.length; x++) 
        {  
            toggleDisabled(el.childNodes[x]);
        }
    }
}

function IframeSrc_AddData(Control,CN,Hid,OrderNo)
{   
    var itemControl = "";
    var splitControl = Control.split(',');
    document.getElementById("divright").style.display='none';    
    document.getElementById("text_div").style.display='block';
    document.getElementById("text_default").style.display='none';
    
     var boderclass= "";
    for(i=0; i< splitControl.length; i++)
    {
    
      if(i>0)
        {
            boderclass= "border_top_dotted";
        }     
        if(splitControl[i] == "AddText")
        {   
            itemControl += "<div id=\"divAddText1\" class=\"float_left "+ boderclass +" padding_top10 padding_bottom10 cursor_pointer width300\" onclick=\"IframeSrc_Data('"+splitControl[i]+"','"+CN+"','"+Hid+"','"+Hid+"','');\"><div class=\"float_left width25 margin_right5\"><img alt=\"AddText\" title=\"AddText\" src=\"images/banner_icon.gif\" /></div><div class=\"float_left width250\">Add Text</div></div>";
        }
        if(splitControl[i] == "AddHeaderWithText")
        {   
            itemControl += "<div id=\"divHeaderText1\" class=\"float_left "+ boderclass +" padding_top10 padding_bottom10 cursor_pointer width300\" onclick=\"IframeSrc_Data('"+splitControl[i]+"','"+CN+"','"+Hid+"','"+Hid+"','');\"><div class=\"float_left width25 margin_right5\"><img alt=\"Header Text\" title=\"Header Text\" src=\"images/banner_icon.gif\" /></div><div class=\"float_left width250\">Header Text</div></div>";
        }
        if(splitControl[i] == "AddImageWithText")
        {   
            itemControl += "<div id=\"divImagewithText1\" class=\"float_left "+ boderclass +" padding_top10 padding_bottom10 cursor_pointer width300\" onclick=\"IframeSrc_Data('"+splitControl[i]+"','"+CN+"','"+Hid+"','"+Hid+"','');\"><div class=\"float_left width25 margin_right5\"><img alt=\"Image Text\" title=\"Image Text\" src=\"images/img_text.gif\" /></div><div class=\"float_left width250\">Image with text</div></div>";
        }
        if(splitControl[i] == "AddFlash")
        {   
            itemControl += "<div id=\"divFlash1\" class=\"float_left "+ boderclass +" padding_top10 padding_bottom10 cursor_pointer width300\" onclick=\"IframeSrc_Data('"+splitControl[i]+"','"+CN+"','"+Hid+"','"+Hid+"','');\"><div class=\"float_left width25 margin_right5\"><img alt=\"Flash\" title=\"Flash\" src=\"images/page_white_flash.png\" /></div><div class=\"float_left width250\">Flash</div></div>";
        }
        if(splitControl[i] == "AddTL")
        {   
            itemControl += "<div id=\"divTextLink1\" class=\"float_left "+ boderclass +" padding_top10 padding_bottom10 cursor_pointer width300\" onclick=\"IframeSrc_Data('"+splitControl[i]+"','"+CN+"','"+Hid+"','"+Hid+"','','"+OrderNo+"');\"><div class=\"float_left width25 margin_right5\"><img alt=\"Text Link\" title=\"Text Link\" src=\"images/layout.png\" /></div><div class=\"float_left width250\">Text Link</div></div>";
        }
        if(splitControl[i] == "AddForms")
        {   
            itemControl += "<div id=\"divForm1\" class=\"float_left "+ boderclass +" padding_top10 padding_bottom10 cursor_pointer width300\" onclick=\"IframeSrc_Data('"+splitControl[i]+"','"+CN+"','"+Hid+"','"+Hid+"','');\"><div class=\"float_left width25 margin_right5\"><img alt=\"Form\" title=\"Form\" src=\"images/application_form.png\" /></div><div class=\"float_left width250\">Form</div></div>";
        }        
        if(splitControl[i] == "Add_Channels_Item")
        {   
            itemControl += "<div id=\"divRP1\" class=\"float_left "+ boderclass +" padding_top10 padding_bottom10 cursor_pointer width300\" onclick=\"IframeSrc_Data('"+splitControl[i]+"','"+CN+"','"+Hid+"','"+Hid+"','');\"><div class=\"float_left width25 margin_right5\"><img alt=\"Recent Productions\" title=\"Recent Productions\" src=\"images/banner_icon.gif\" /></div><div class=\"float_left width250\">Recent Productions</div></div>";
        }
        if(splitControl[i] == "Add_Programming_Clips")
        {   
            itemControl += "<div id=\"divProgC1\" class=\"float_left "+ boderclass +" padding_top10 padding_bottom10 cursor_pointer width300\" onclick=\"IframeSrc_Data('"+splitControl[i]+"','"+CN+"','"+Hid+"','"+Hid+"','');\"><div class=\"float_left width25 margin_right5\"><img alt=\"File Uploader\" title=\"File Uploader\" src=\"images/application.png\" /></div><div class=\"float_left width250\">Programming Clips</div></div>";
        }
        if(splitControl[i] == "History")
        {   
            itemControl += "<div id=\"divHistory1\" class=\"float_left "+ boderclass +" padding_top10 padding_bottom10 cursor_pointer width300\" onclick=\"IframeSrc_Data('"+splitControl[i]+"','"+CN+"','"+Hid+"','"+Hid+"','');\"><div class=\"float_left width25 margin_right5\"><img alt=\"Recent Productions\" title=\"Recent Productions\" src=\"images/banner_icon.gif\" /></div><div class=\"float_left width250\">History</div></div>";
        }
        if(splitControl[i] == "Release_Link")
        {   
            itemControl += "<div id=\"divRelLink1\" class=\"float_left "+ boderclass +" padding_top10 padding_bottom10 cursor_pointer width300\" onclick=\"IframeSrc_Data('"+splitControl[i]+"','"+CN+"','"+Hid+"','"+Hid+"','');\"><div class=\"float_left width25 margin_right5\"><img alt=\"Release Link\" title=\"Release Link\" src=\"images/banner_icon.gif\" /></div><div class=\"float_left width250\">Release Link</div></div>";
        }
        if(splitControl[i] == "AddHeadlineImageWithText")
        {   
            itemControl += "<div id=\"divHeadImagewithText1\" class=\"float_left "+ boderclass +" padding_top10 padding_bottom10 cursor_pointer width300\" onclick=\"IframeSrc_Data('"+splitControl[i]+"','"+CN+"','"+Hid+"','"+Hid+"','');\"><div class=\"float_left width25 margin_right5\"><img alt=\"HeadlineImage with Text\" title=\"HeadlineImage with Text\" src=\"images/banner_icon.gif\" /></div><div class=\"float_left width250\">HeadlineImage with Text</div></div>";
        }
        if(splitControl[i] == "AddBiography")
        {   
            itemControl += "<div id=\"AddBiography1\" class=\"float_left "+ boderclass +" padding_top10 padding_bottom10 cursor_pointer width300\" onclick=\"IframeSrc_Data('"+splitControl[i]+"','"+CN+"','"+Hid+"','"+Hid+"','');\"><div class=\"float_left width25 margin_right5\"><img alt=\"HeadlineImage with Text\" title=\"HeadlineImage with Text\" src=\"images/banner_icon.gif\" /></div><div class=\"float_left width250\">Biography</div></div>";
        }
        if(splitControl[i] == "AddCareers")
        {
            itemControl += "<div id=\"divCareers1\" class=\"float_left "+ boderclass +" padding_top10 padding_bottom10 cursor_pointer width300\" onclick=\"IframeSrc_Data('"+splitControl[i]+"','"+CN+"','"+Hid+"','"+Hid+"','');\"><div class=\"float_left width25 margin_right5\"><img alt=\"Career\" title=\"Career\" src=\"images/banner_icon.gif\" /></div><div class=\"float_left width250\">Career</div></div>";
        }        
        if(splitControl[i] == "AddNewsContent")
        {
            itemControl += "<div id=\"AddNewsContent1\" class=\"float_left "+ boderclass +" padding_top10 padding_bottom10 cursor_pointer width300\" onclick=\"IframeSrc_Data('"+splitControl[i]+"','"+CN+"','"+Hid+"','"+Hid+"','');\"><div class=\"float_left width25 margin_right5\"><img alt=\"AddNewsContent\" title=\"AddNewsContent\" src=\"images/banner_icon.gif\" /></div><div class=\"float_left width250\">AddNewsContent</div></div>";
        }
        if(splitControl[i] == "AddFlashVideo")
        {
            itemControl += "<div id=\"AddFlashVideo1\" class=\"float_left "+ boderclass +" padding_top10 padding_bottom10 cursor_pointer width300\" onclick=\"IframeSrc_Data('"+splitControl[i]+"','"+CN+"','"+Hid+"','"+Hid+"','');\"><div class=\"float_left width25 margin_right5\"><img alt=\"AddFlashVideo\" title=\"AddFlashVideo\" src=\"images/banner_icon.gif\" /></div><div class=\"float_left width250\">Add Video</div></div>";
        }
    }
    document.getElementById("divitemControl").innerHTML = itemControl;
}

/*****End By Arti****/


/*******************Function Added by Kajal on 23/03/2009 ****************************/
function CallFlashDefault(Hid)
{
    var temp = 'FlashDefault.aspx?dispID=' + Hid
    document.getElementById("divright").style.display='block';
    //document.getElementById("MasterFrame").style.display='block';
    document.getElementById("text_div").style.display='none';
    //document.getElementById('MasterFrame').src = temp;
//    document.getElementById('MasterFrame').src = temp;
//    document.getElementById("fade").style.display='block';
    return false;
}
/*******************Function Ended by Kajal on 23/03/2009 ****************************/



/********** Added By Hiren ******/
function Clickheretoprint(Print_Text)
{   
    var disp_setting="toolbar=no,location=no,directories=no,menubar=no,"; 
      disp_setting+="scrollbars=yes,width=650, height=600, left=100, top=25"; 
    var content_vlue = Print_Text.replace("%20", " ").replace("~", "'");
  
    var docprint=window.open("","",disp_setting);
    docprint.document.open(); 
    docprint.document.write('<html><head><title>Biography</title><link rel=\"stylesheet\" type=\"text/css\" href=\"factualscroll/ContentItemPage.css\" />'); 
    docprint.document.write('</head><body onLoad="self.print()" class=\"popupText\" style=\"font-family:Tahoma;font-size:0.8em;\">');          
    docprint.document.write(content_vlue);          
    docprint.document.write('</body></html>'); 
    docprint.document.close(); 
    docprint.focus(); 
}

function Delete_Data(Control,CN,Id,Hid,Cid)
{   
    if (confirm("Are you sure you want to delete")) 
    {  
        var temp;
        if(Cid != '')
        {        
            temp = Control + '.aspx?CN=' + CN + '&id=' + Id +'&dispID=' + Hid + '&cid=' + Cid +'&Del=Del';
        }
        document.getElementById('newIFrame').innerHTML = "<iframe id=\"MasterFrame\" src=\""+temp+"\" width=\"388\" height=\"1030px\" scrolling=\"no\" class=\"float_left \" frameborder=\"0\"></iframe>";
       
        window.location.reload();
    }
}


/*********** End By Hiren **************/
/***********function added by arti*****************/

function border_effect_top(flag, ID,ID2)
{
    if (flag==0)
    {
        document.getElementById(ID).className = "flotlt borderBlue_top";
        document.getElementById(ID2).className = "flotlt borderBlue";
        
    }
    else
    {
       document.getElementById(ID).className = "flotlt borderWhite_top";
       document.getElementById(ID2).className = "flotlt borderWhite";
    }
}

function border_effect_both(flag, ID,ID2)
{
    if (flag==0)
    {
        document.getElementById(ID).className = "flotlt borderBlue";
        document.getElementById(ID2).className = "flotlt borderBlue_top";
    }
    else
    {
       document.getElementById(ID).className = "flotlt borderWhite";
       document.getElementById(ID2).className = "flotlt borderWhite_top";
    }
}
/**************ENDS HERE********/

function bindProgrmmingClips(bingString)
{   
    bingString = replaceAll(bingString,"`","\"");
    bingString = replaceAll(bingString,"~","'");
    document.getElementById("divright").style.display='block';
    document.getElementById('newIFrame').innerHTML = bingString;
    jQuery('#programming-carousel').jcarousel({
    vertical:true,
    scroll:6
    }); 

}

function headerwidth()
{

   var yWithScroll;
   var xWithScroll;
     
    if ((window.innerHeight && window.scrollMaxY) || (window.innerWidth && window.scrollMaxX)) // Firefox
    {
      
        yWithScroll = window.innerHeight + window.scrollMaxY;
        xWithScroll = window.innerWidth + window.scrollMaxX;
        
    }
    else if (document.body.scrollWidth > document.body.offsetWidth) // all Google Chrome, Safari but Explorer Mac
    { 
    
        yWithScroll = document.body.scrollHeight;
        xWithScroll = document.body.scrollWidth;
    } 
    else // works in Explorer 6 Strict, Mozilla (not FF) IE6,IE7
    { 	
   
        yWithScroll = document.body.offsetHeight;
        xWithScroll = document.body.offsetWidth;
    } 
 
    if( document.getElementById('heading_edit')!=null)
        document.getElementById('heading_edit').style.width=xWithScroll+"px"; 
  if( document.getElementById('divPreview')!=null)
    document.getElementById('divPreview').style.width=xWithScroll+"px";
  if( document.getElementById('divfoot')!=null)
    document.getElementById('divfoot').style.width=xWithScroll+"px";
}