﻿// JScript File

function GetxmlHttp() 
{
    var xmlHttp;
    try
    {
        xmlHttp=new XMLHttpRequest();
    }
    catch (e)
    {
        try
        {
            xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e)
        {
            try
            {
                xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch (e)
            {
                alert("Your browser does not support AJAX!"); 
                return false;
            }
        }
    } 
    return xmlHttp;
}

function GenDropDownList(tdid,mainid,imgid,viewidx) 
{
    var obj = document.getElementById(tdid);
    if (obj == null) {
        obj = tdid;
    } 
    obj.innerHTML = "<img src='Images/spinner.gif' alt='' />"
    var xmlHttp = GetxmlHttp();
    xmlHttp.onreadystatechange=function()
    {
        if(xmlHttp.readyState==4)
        {
            var result = xmlHttp.responseText;
            obj.innerHTML = xmlHttp.responseText;
        }
        else
        {
        }
    }
    xmlHttp.open("GET","ajaxganeral.ashx?viewidx="+viewidx+"&mid="+mainid,true);
    xmlHttp.send(null);
}

function Validation()
{
    var NoText = " Required fields!";
    var EmailFormatValid = "Email format valid!";
    var URLFormatValid = "URL format valid!";
    for (i=0;i<arguments.length;i++) {
        var nonformat = 0;
        var emailformat = 1;
        var urlformat = 2;
        
        var first = arguments[i]; // Ctrl
	    var second = arguments[i+1]; // Label or Span Show Error
	    var third = arguments[i+2]; // Type Check -- 0 no type , 1 email type , 2 url type
	    var forth = arguments[i+3]; // 0 Not require , 1 Require
	    
	    var TRtype = document.getElementById("ctl00_ContentPlaceHolder1_TRType");
	    var TRsubtype =document.getElementById("ctl00_ContentPlaceHolder1_TRSubtype");
	    var type =document.getElementById("ctl00_ContentPlaceHolder1_DDType");
	    var lbtype =document.getElementById("ctl00_ContentPlaceHolder1_lbltype");
	    var subtype =document.getElementById("ctl00_ContentPlaceHolder1_DDSubType");
	    var lbsubtype=document.getElementById("ctl00_ContentPlaceHolder1_lblsubtype");
	    i = i+3;
        var ctrl = document.getElementById(first);
        var lbl = document.getElementById(second); 
        
       
        if (TRtype.style.display==''){
            if(type.value=="0" || type.value==""){
                lbtype.innerHTML=" * " + NoText ;
                return false;
            }else{lbtype.innerHTML=" *";}
            
            if (TRsubtype.style.display==''){
                if(subtype.value=="0" || subtype.value==""){
                    lbsubtype.innerHTML=" * " + NoText ;
                    return false;
                }else{lbsubtype.innerHTML=" *";}
            }
        }
        if (forth == 1) {
            if ((ctrl != null) && (ctrl.value == "")) {
                //lbl.firstChild.nodeValue = " * " + NoText;
                lbl.innerHTML = " * " + NoText ;
                ctrl.focus();
                return false;
            } else {
                if (lbl != null) {
                    lbl.firstChild.nodeValue=' * ';
                }  
            }
        }   
        if ((ctrl != null) && (ctrl.value != "")) {
            if (third == emailformat) {
                var emailPat = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*\.(\w{2}|(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum))$/;            
                var matchArray = emailPat.test(ctrl.value);
                if (matchArray == false)
                {
                   lbl.firstChild.nodeValue = " * " + EmailFormatValid;
                   ctrl.focus();
                   return false;
                } else {
                    if (lbl != null) {
                        lbl.firstChild.nodeValue=' * ';
                    } 
                }
            } /*else if (third == urlformat) {
                var regexp = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/;          
                var matchArray = regexp.test(ctrl.value);
                if (matchArray == false)
                {  
                   lbl.firstChild.nodeValue = " * " + URLFormatValid;
                   ctrl.focus();
                   return false;
                } else {
                    if (lbl != null) {
                        lbl.firstChild.nodeValue=' * ';
                    } 
                }
            } */      
        }       
    }
}


function AllowOnlyNumbers(e) 
{ 
    var intKey = (e.keyCode) ? e.keyCode : e.which;
    intKey = (intKey) ? intKey : window.event.keyCode;
    if (((intKey >= 48) && (intKey <= 57)) || (intKey == 8)) {
    } else {
        return false;
    }
    
} 

function PopupTable(CtrlIframe,aid,iid,width,height,from)
{
    var div;
    var closediv;
    var scaleX = (screen.width - width) / 2;
    var scaleY = 60;
    if (from == "ImageAd") {
        div = document.getElementById("ctl00_ContentPlaceHolder1_Div");
        closediv = document.getElementById("ctl00_ContentPlaceHolder1_DivEmailToFriend");
    } else {
         div =  document.getElementById("ctl00_ContentPlaceHolder1_DivEmailToFriend");
         closediv = document.getElementById("ctl00_ContentPlaceHolder1_Div");
         scaleY = (screen.height - height - 230) / 2;
    }
    closediv.style.display = 'none';
    var posx = 0;
    var posy = 0;
    var xy = getScrollXY();
    var IE = document.all ? true : false;
    if (IE) { // grab the x-y pos.s if browser is IE
        posx = scaleX + xy[0];
        posy = scaleY + xy[1];
    } else {  // grab the x-y pos.s if browser is NS
        posx = scaleX + xy[0];
        posy = scaleY + xy[1];
    } 
    div.style.display = 'block';
    div.style.left = (posx)+'px';
    div.style.top = (posy)+'px';  
    var doc = jQuery(window);
    if (from == "ImageAd") {
        var ifm =  document.getElementById(CtrlIframe);
        if (ifm == null) {
            ifm = CtrlIframe;
        }
        ifm.src = 'showadphoto.aspx?aid='+aid+'&iid='+iid;
        doc.scroll(function(){
        div.style.top = (doc.scrollTop()+60) +"px";
        }); 
    } else {
        doc.scroll(function(){
            div.style.top = (doc.scrollTop()+130) +"px";
        }); 
    }
}

function getScrollXY() 
{
    var scrOfX = 0, scrOfY = 0;
    if (typeof(window.pageYOffset) == 'number') {
        //Netscape compliant
        scrOfY = window.pageYOffset;
        scrOfX = window.pageXOffset;
    } else if (document.body && (document.body.scrollLeft || document.body.scrollTop)) {
        //DOM compliant
        scrOfY = document.body.scrollTop;
        scrOfX = document.body.scrollLeft;
    } else if(document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop)) {
        //IE6 standards compliant mode
        scrOfY = document.documentElement.scrollTop;
        scrOfX = document.documentElement.scrollLeft;
    }
    return [scrOfX,scrOfY];
}

function CloseDiv(div,IFrame,from)
{
    var div = document.getElementById(div);
    div.style.display='none';
    var ifm = document.getElementById(IFrame);
    if (from == "ImageAd") {
        
        ifm.src = 'showadphoto.aspx'
    } else {
        ifm.src = 'emailtofriend.aspx'
    }
}

function Redirect(aid,iid)
{
    window.location = 'showadphoto.aspx?aid='+aid+'&iid='+iid;
    return false;
}

function ShowHideContact(idname,tbshow,tbhide,txtshow,txthide)
{
    var hid = document.getElementById("ctl00_ContentPlaceHolder1_HidLogin");
    if (hid != null) {
        if (idname == 'NonMem') {
	            hid.value = 'Login';
        } else {
                hid.value = 'ContactNonMember';
        }
    }
    var tbshow = document.getElementById(tbshow);
    var tbhide = document.getElementById(tbhide);
    var txtshow = document.getElementById(txtshow);
    var txthide = document.getElementById(txthide);
    tbshow.style.display = '';
    tbhide.style.display = 'none';
    txtshow.style.display = '';
    txthide.style.display = 'none';
}

function UpdateCoverImage(rdoid,adid,imgid,viewidx) 
{
    var obj = document.getElementById(rdoid);
    if (obj == null) {
        obj = rdoid;
    } 
    var xmlHttp = GetxmlHttp();
    xmlHttp.onreadystatechange=function()
    {
        if(xmlHttp.readyState==4)
        {         
        }
    }
    xmlHttp.open("GET","ajaxganeral.ashx?viewidx="+viewidx+"&adid="+adid+"&imgid="+imgid,true);
    xmlHttp.send(null);
}

function UpdateAdvPost(rdoid,TBname,Field,advid,viewidx) 
{
    var obj = document.getElementById(rdoid);
    if (obj == null) {
        obj = rdoid;
    } 
    var Value=obj.options[obj.selectedIndex].value;
    var xmlHttp = GetxmlHttp();
    xmlHttp.open("GET","../../ajaxganeral.ashx?viewidx="+viewidx+"&tbname="+TBname+"&field="+Field+"&value="+Value+"&advid="+advid,true);
    
    xmlHttp.onreadystatechange=function()
    {
        if(xmlHttp.readyState==4)
        {   
         }
    }
    
    xmlHttp.send(null);
}
function SendContactTodating(dd,imgx,mid,advid){
    if(mid==""){ 
        var ab =window.location+'';
        var xx =ab.split("/");
        window.location = 'gingerasia_member_area_login.aspx?lasturl=%2f'+xx[xx.length-1];
        return false;
    }  
//    var ImgPath =  "Images/" ;
//    var obj = document.getElementById(imgx);
//    
//    if (obj != null) {
//    var oldobj = obj.innerHTML ;
//    obj.innerHTML =  "<img src='" + ImgPath + "spinner.gif' alt='' />"
//     
//    var xmlHttp = GetxmlHttp();
//    xmlHttp.open("GET","ajaxganeral.ashx?viewidx=8&id="+advid,true);
//    
//    xmlHttp.onreadystatechange=function()
//    {
//        if(xmlHttp.readyState==4)
//        {   var result =xmlHttp.responseText;
//            if(result=='0'){alert("Not Send Message !"); obj.innerHTML = oldobj;}
//            if(result=='1'){
//                obj.innerHTML ="<img src='" +  ImgPath + "lovemessagefl_off.jpg' alt='' />";
//            }
//            
//         }
//         
//    }
//    xmlHttp.send(null);
//    }
}

function UpdateAdvuse(rdoid,advid,DDname,viewidx) 
{   
    var DD = document.getElementById(DDname);
    
    var ImgPath =  "../../Images/" ;
    var obj = document.getElementById('img_' + advid);
    
    if (obj != null) {
    var oldobj = obj.innerHTML ;
    
   // var Value=obj.options[obj.selectedIndex].value;
    obj.innerHTML = "<img src='"+ ImgPath + "spinner.gif' alt='' />"
   
    var xmlHttp = GetxmlHttp();
    xmlHttp.open("GET","../../ajaxganeral.ashx?viewidx="+viewidx+"&adid="+advid,true);
    
    xmlHttp.onreadystatechange=function()
    {
        if(xmlHttp.readyState==4)
        {   var result =xmlHttp.responseText;
            //result = "1" ;
            if(result=='3'){alert("Can Not Change Use Because Now Old Payment not Expired."); obj.innerHTML = oldobj;}
            else if(result=='2'){alert("Can Not Use If Payment not complete!"); obj.innerHTML = oldobj;}
            else if(result=='1'){obj.innerHTML =   "<img src='"+ ImgPath + "tick.gif' alt='' />";if (DD != null){DD.style.display = 'none';}}
         }
         
    }
    xmlHttp.send(null);
    }
}



function Rating(adid) 
{   
    var val = -1;
    for (var i=1;i<=10;i++) {
        var rdo = document.getElementById('RdoRate'+i);
        if (rdo.checked == true) {
             val = rdo.value;
        }
    }

    var xmlHttp = GetxmlHttp();
    xmlHttp.onreadystatechange=function()
    {
        if(xmlHttp.readyState==4)
        {
            var result = xmlHttp.responseText;
            if (result != "") {
                var textsplit = result.split(",")
                var text = textsplit[0];
                var avg = textsplit[1];
                var total = textsplit[2];
                var tbold = document.getElementById("TBRate");
                var tb = document.getElementById("TBRateSuccess");
                tbold.style.display='none';
                tb.style.display = '';
                var td = document.getElementById("TDRateSuccess");
                td.innerHTML = text;  
                var lbl = document.getElementById("ctl00_ContentPlaceHolder1_LblRate");
                
                if (lbl != null) {
                    lbl.style.display='';
                    var strvote="";
                    if(total>1){strvote="s";}
                    lbl.innerHTML="<b>Customer rating:</b> " + avg + " from " + total + " vote"+strvote;
                }
            }
        }
        else
        {
        }
    } 
    xmlHttp.open("GET","ajaxganeral.ashx?viewidx=3&adid="+adid+"&rate="+val,true);
    xmlHttp.send(null); 
}

if(window.addEventListener) { //Support FireFox
	window.addEventListener('load', function(){ CheckMemberAds(); },false);
	//window.addEventListener('load', function(){ Scroller(); },false);
} else if (window.attachEvent) { //Support IE
	window.attachEvent('onload', function(){ CheckMemberAds();});
	//window.attachEvent('onload', function(){ Scroller();});
}
function CheckMemberAds()
{
	var hid = document.getElementById("ctl00_ContentPlaceHolder1_HidLogin");
	if (hid != null) {
        if (hid.value == 'Login') {
            ShowHideContact('NonMem','TRLogin','ctl00_ContentPlaceHolder1_TRContactNonMember','ctl00_ContentPlaceHolder1_TRTextMem','ctl00_ContentPlaceHolder1_TRTextNonMem');
        }
    } 
}

function ClosePopup()
{
    var div =  document.getElementById("pop_up");
    if(div) div.style.display = 'none';
}


function Popup(e,des,divwidth,title)
{
    var div =  document.getElementById("pop_up");
    if(div){
    
        var IE = document.all ? true : false;
        
        div.style.display = 'block';
        if (divwidth != 0) {
            div.style.width = (divwidth)+'px';
        } else {
            div.style.width = (250)+'px';
        }
        
        var head =  document.getElementById("pop_head");
        if(title) head.innerHTML = unescape(title); else head.innerHTML = "";
        
        var body =  document.getElementById("pop_up_body");
        body.innerHTML = unescape(des) ;
        if(IE){
            var iframe = document.getElementById("iframe_pop");
            iframe.style.display = 'inline';
	        iframe.style.width = div.clientWidth +'px';
	        iframe.style.height = div.clientHeight +'px';
        }
        // set poxsition
        var elW = div.offsetWidth;
        var elH = div.offsetHeight;
        var docW = 0;
        var docH = 0;
        var cPosx = 0;
        var cPosy = 0;
        var posx = 0;
        var posy = 0;
        
        var xy = getScrollXY();
        
        if (IE) { // grab the x-y pos.s if browser is IE
            docW = document.documentElement.clientWidth;
            docH = document.documentElement.clientHeight;
            cPosx = event.clientX;
            cPosy = event.clientY;
            posx = cPosx + xy[0]+10;
            posy = cPosy + xy[1];
        } else {  // grab the x-y pos.s if browser is NS
            docW = window.innerWidth;
            docH = window.innerHeight;
            cPosx = e.clientX;
            cPosy = e.clientY;
            posx = e.pageX+10;
            posy = e.pageY;
        } 
        
        if((docH-cPosy) < (elH+30)) posy = (posy - elH);
        if((docW-cPosx) < (elW+30)) posx = (posx - (elW+20));
        
        div.style.left = (posx)+'px' ;
        div.style.top = (posy)+'px' ; 
    } 
}

function WindowPrint(servername,aid)
{
    var width = 600;
    var height = 500;
    var left = (screen.width - width) / 2;
    var top = (screen.height - height) / 2;
    window.open("http://" + servername + "/printadvert.aspx?aid=" + aid,"","width=" + width + ",height=" + height + ",left=" + left + ",menubar=yes,scrollbars=yes,resizable=no");
}

function VisibleCarBike(type)
{
    var TB =  document.getElementById("TBCarBike");
    TB.style.display = '';
    var TBCar =  document.getElementById("TBCar");
    if (type == 'Car') {       
        TBCar.style.display = '';
    } else if (type == 'Bike') {
        TBCar.style.display = 'none';
    }
}

function VisiblePrice(GCat,nameUcinsertAds)
{
    //var nameurlselectpage ="ctl00_ContentPlaceHolder1_InertAds1_";
    var nameurlselectpage =nameUcinsertAds+"_";
    //var mainpage ="ctl00_ContentPlaceHolder1_";
    var val = GCat.value;
    var textsplit = val.split('_');
    val = textsplit[2];   
    //alert(val);
    var TRSale =  document.getElementById(nameurlselectpage+"TRSale");
    var TRwant =  document.getElementById(nameurlselectpage+"TRWant");
    
    var trSrent= document.getElementById(nameurlselectpage+"trSrent");
    var trSDDrenttime= document.getElementById(nameurlselectpage+"trSDDrenttime");
    var trWrent= document.getElementById(nameurlselectpage+"trWrent");
    var trWDDrenttime= document.getElementById(nameurlselectpage+"trWDDrenttime");
         trSrent.style.display='';
        trSDDrenttime.style.display='';
        trWrent.style.display='';
        trWDDrenttime.style.display='';
    var Wlbsale= document.getElementById("Wlbsale");
    var Slbsale=document.getElementById("Slbsale");
    
    var WlbWant=document.getElementById("WlbWant");
    var SlbWant=document.getElementById("SlbWant");
    
    var TRB2B =  document.getElementById(nameurlselectpage+"TRB2B");
   /* var TRauction= document.getElementById(nameurlselectpage+"TRAuction");
    var TRRreserved= document.getElementById(nameurlselectpage+"TRreserved");
    var TRCeetified= document.getElementById(nameurlselectpage+"TRCeetified");
    TRauction.style.display='none';
    TRRreserved.style.display='none';
    TRCeetified.style.display='none';
    */
    
    var TRType = document.getElementById(nameurlselectpage+"TRType");
    var TRSubtype = document.getElementById(nameurlselectpage+"TRSubtype");
    var lbTRtype = document.getElementById("lbtrtype");
    var lbTRsubtype = document.getElementById("lbsubtype");
    
    var ddcategory =GCat;//document.getElementById("CategoryID");
    var lbcategoryselect= document.getElementById("lbcategoryselect");
    var lbcategoryselect2= document.getElementById("lbcategoryselect2");
    //alert("xxx"+ ddcategory.options[ddcategory.selectedIndex].text);
    
    lbcategoryselect.innerHTML= ddcategory.options[ddcategory.selectedIndex].text
    lbcategoryselect2.innerHTML= ddcategory.options[ddcategory.selectedIndex].text
    
    TRType.style.display='none';
    TRSubtype.style.display='none';
    TRSale.style.display='none';
    TRwant.style.display='none';
    TRB2B.style.display='none';
    Wlbsale.innerHTML="Buy";
    Slbsale.innerHTML="Sell";
    
    WlbWant.style.display = '' ;
    SlbWant.style.display = '' ;
    
    if (val == 0) {

    } else if (val == 1) {
        TRSale.style.display='';
        TRwant.style.display='';
        
    } else if (val == 2) {
    //sale Price only
        TRSale.style.display='';
        TRwant.style.display='';
        trSrent.style.display='none';
        trSDDrenttime.style.display='none';
        trWrent.style.display='none';
        trWDDrenttime.style.display='none';
    
    } else if (val == 3) {
       // TRB2B.style.display='';
    } else if (val == 4) {
        //salary
        TRSale.style.display='';
        TRwant.style.display='';
        trSrent.style.display='none';
        trSDDrenttime.style.display='none';
        trWrent.style.display='none';
        trWDDrenttime.style.display='none';
        
        WlbWant.style.display = 'none' ;
        SlbWant.style.display = 'none' ;
        
        Wlbsale.innerHTML="Salary";
        Slbsale.innerHTML="Salary";
        
        lbTRtype.innerHTML="Job Position";
        lbTRsubtype.innerHTML="";
        TRType.style.display='';
        
    }else if (val == 5) {
        TRType.style.display='';
        lbTRtype.innerHTML="Seeking";
        lbTRsubtype.innerHTML="Relationship";
        TRSubtype.style.display='';
    }
//    if (val==4 || val==5){
//        if (val==4){lbTRtype.innerHTML="Job Position";lbTRsubtype.innerHTML="";}
//       TRType.style.display='';
//        if (val==5){lbTRtype.innerHTML="Seeking";lbTRsubtype.innerHTML="Relationship";TRSubtype.style.display='';}

//    }
}

function SendTo4B(AdID) {
    var xmlHttp = GetxmlHttp();
    xmlHttp.onreadystatechange=function()
    {
        if(xmlHttp.readyState==4)
        {         
        }
    }
    xmlHttp.open("GET","http://www.4bangkok.com/4bangkok/gingermember.asp?.AdsId=" + AdI,true);
    xmlHttp.send(null);
}
function openNewWindow(url, h, w) {
var oNewWindow;
oNewWindow = window.open(url, null, "left=" + (screen.width - w) / 2 + ",top=" + (screen.height - h) / 2 + ",height=" + h + ",width=" + w + ",status=yes,resizable=yes,toolbar=no,scrollbars=yes,menubar=no,location=no");
}
function validateImg(T1,D1,F1,span){ 
 
    var ch_Fup = true;
    var t =0;
    var k=0;
    for(var i=0;i<3;i++){
     if (i==0){
     j='';
     }else{
      j=i;
     }
     if(((document.getElementById(T1+j).value!='')||(document.getElementById(D1+j).value!=''))&&(document.getElementById(F1+j).value=='')){
     document.getElementById(span+j).innerHTML=' * Required';
     document.getElementById(T1+j).focus();
      ch_Fup = false;
     
     }else{
      if ((document.getElementById(T1+j).value=='')&&(document.getElementById(F1+j).value!='')){
             document.getElementById('Title'+span+j).innerHTML=' * Required';
             document.getElementById(T1+j).focus();
             ch_Fup = false;
           }else{
     k=k+1;
     document.getElementById('Title'+span+j).innerHTML=''
     document.getElementById(span+j).innerHTML='' }
     if(document.getElementById(F1+j).value==''){
     t=t+1;
     }
    }
    }
    
     var chbox=true;
     if ((t==3)&&(k==3)){
     //document.getElementById(span).innerHTML=' * Required';
     //document.getElementById(T1).focus();
     // ch_Fup = false;
    }else{
    chbox=chkbox();// chk checkbox Terms 
    }
    var chD = true;
        chD=chklenght(D1) // chk length text >170

     return chD&&ch_Fup&&chbox;
 }
 
 function desclen(desc1,span){ 
    var desc=document.getElementById(desc1).value;
    var sp=document.getElementById(span);
    if(trim(desc).length >170)
    {
        sp.innerHTML="<br/>Please limit the description to 170 characters.";return false;
    }
    else
    {
        sp.innerHTML='';return true;
    }
 }
 
 
  function chkbox(){
   var chkbox = true;
  // for (i=0;i<document.aspnetForm.elements.length;i++){
     elm = document.getElementById("ctl00_ContentPlaceHolder1_ChkBoxTerms") ||  document.getElementById("ctl00_ContentPlaceHolder1_AdvertisePic1_ChkboxTerms") || document.getElementById("ctl00_ContentPlaceHolder1_ChkBoxTermOther") ;  //document.aspnetForm.elements[i]
     //if(elm.type == 'checkbox'){
     
       if (elm.checked==false){
          chkbox= false;
           if (document.getElementById('chkTerms')){
            document.getElementById('chkTerms').innerHTML='* Required';
            }else{
            document.getElementById('chkTerms1').innerHTML='* Required';}
       
          }else{ 
            if (document.getElementById('chkTerms')){
            document.getElementById('chkTerms').innerHTML='';
           }else{
           document.getElementById('chkTerms1').innerHTML='';
          }
         
        } // if
      //} // if 
  //  }  // for 
    return chkbox;
  }
  function chkedit(F1,D1,t1){
    var chD = true;
        chD=chklenght(D1) // chk length text >170
    var chbox=true;
    if (document.getElementById(F1).value!=''){
        chbox=chkbox();// chk checkbox Terms 
       }
    var ch_titleedit=true;
    var ch_tream=true;
    var titlecomment= document.getElementById("TitleSpnImgReq");
   if (document.getElementById(t1).value==""){
       titlecomment.innerHTML=" * Required";
       ch_titleedit=false;
   }else{titlecomment.innerHTML=" *";}
       
       
   var chtream =document.getElementById("ctl00_ContentPlaceHolder1_AdvertisePic1_ChkboxTerms");
   var reqcheck=document.getElementById("chkTerms");
   if(chtream.checked==false)
    {   ch_tream=false;
        reqcheck.innerHTML=" * Required";
    }else{
        reqcheck.innerHTML=" *";
    }
       
        return chD&&chbox&&ch_titleedit&&ch_tream;
  } 
  
  function chklenght(byid) {
  var ret = true ;
    for(var i=0;i<3;i++){
     if (i==0){
     j='';
     }else{
      j=i;
     }
   var desc 
   if(document.getElementById(byid+j)){
    desc  = document.getElementById(byid+j).value ;
    if (trim(desc).length >170) {
     ret=false;
   
     break;
    } else {
       ret= true;
    }
    
 }
 }
    return ret;
}      
function checklenght(e,byid,div) {
    if (!e) {
        e = window.event;
    }
    
    if (typeof e.which == "number") {
        e = e.which;
    } else if (typeof e.keyCode == "number") {
        e = e.keyCode;
    } else if (typeof e.charCode == "number") {
        e = e.charCode;
    }
  
    var desc = document.getElementById(byid).value ;
   var ret = true ;
  
    if (e == 8 || trim(desc).length <171) {
    document.getElementById(div).innerHTML='';
     
    } else {
       
       // var newdesc = desc.substring(0,171) ; 
       // document.getElementById(byid).value = newdesc ;
         document.getElementById(div).innerHTML = "<br/>Please limit the description to 170 characters." ;
        ret = false ;
    }
    
    return ret;
}

function trim(str) {
return str.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
}

function setforumgroup(forum,viewidx) 
{   
    var obj = document.getElementById("SubCat_"+forum);
 var Value=obj.options[obj.selectedIndex].value;
 var textsplit = Value.split('_');
 var fgupateby =document.getElementById("updateby_Forumgroup_"+forum);
 var oldfgupdateby=fgupateby;
 fgupateby.innerHTML = "<img src='Images/spinner.gif' alt='' />";
   
    var xmlHttp = GetxmlHttp();
    xmlHttp.open("GET","ajaxganeral.ashx?fid="+forum+"&gcid="+textsplit[0]+"&cid="+textsplit[1]+"&viewidx="+viewidx);
    
    xmlHttp.onreadystatechange=function()
    {
        if(xmlHttp.readyState==4)
        {   var result =xmlHttp.responseText;
            if(result=='0'){
                fgupateby.innerHTML=oldfgupdateby.innerHTML;
                alert("Not complete");
            }else{
                alert("Update Complete");
                fgupateby.innerHTML=result;
            }
            
         }
         
    }
    xmlHttp.send(null);
}