function ad_post_on(obj){
   var image_path = obj.src;
   image_path = image_path.replace("_a_", "_b_");
   obj.src = image_path;
}
function ad_post_out(obj){
   var image_path = obj.src;
   image_path = image_path.replace("_b_", "_a_");
   obj.src = image_path;
}

     function select_class(val){
        if(val == 0){
            document.getElementById("class_1").style.display = "block";
            document.getElementById("class_2").style.display = "none";
        }else{
            document.getElementById("class_1").style.display = "none";
            document.getElementById("class_2").style.display = "block";           
        }
    }
 
    function real_search_company(){
     var getStr = "";
    
     var company_name = document.getElementById("company_txt").value;
     if (company_name != ''){
      getStr = "real.php?cname=" + company_name;
     self.location.replace(getStr);
     }
     
    }

function real_js_get_cat(aid, atitle){
     parent.toolPage.document.getElementById("category_id").value = aid;
     parent.toolPage.document.getElementById("category_title").value = atitle;
     var areaid = parent.toolPage.document.getElementById("area_id").value;
     var getStr = "real.php?option=get_cat&catid=" + aid;
     if (areaid != "" && areaid != "-1"){
      getStr += "&areaid=" + areaid; 
     }
     self.location.replace(getStr);
}

function real_js_get_area(val,sid){
 parent.toolPage.document.getElementById("area_id").value = val;
 parent.toolPage.document.getElementById("area_title").value = sid;
 var catid = parent.toolPage.document.getElementById("category_id").value;
 var getStr = "real.php?option=get_area&areaid=" + val;
 //var cname = parent.toolPage.document.getElementById("company_id").value;
 
 if(catid != "" && catid != "-1"){
  getStr += "&catid=" + catid;
 }
 //if (cname != ''){getStr +="&cname=" + cname; }
 self.location.replace(getStr);
}  

/*  ----- break line  */

function checkEnter(e){ //e is event object passed from function invocation
var characterCode //literal character code will be stored in this variable

if(e && e.which){ //if which property of event object is supported (NN4)
e = e
characterCode = e.which //character code is contained in NN4's which property
}
else{
e = event
characterCode = e.keyCode //character code is contained in IE's keyCode property
}

if(characterCode == 13){ //if generated character code is equal to ascii 13 (if enter key)
search_company(); //submit the form
return false
}
else{
return true
}

}


    function search_company(){
     var getStr = "";
    
     var company_name = document.getElementById("company_txt").value;
     if (company_name != ''){
      getStr = "yp.php?cname=" + company_name;
      //parent.toolPage.document.getElementById("company_id").value = company_name;
     //var catid = parent.toolPage.document.getElementById("category_id").value; 
     //var areaid = parent.toolPage.document.getElementById("area_id").value ;
     //if(catid != "" && catid != "-1"){
     /* getStr += "&catid=" + catid;
     }
     if (areaid != "" && areaid != "-1"){
      getStr += "&areaid=" + areaid; 
     }*/
     self.location.replace(getStr);
     }
     
    }

function js_get_cat(aid, atitle){
     parent.toolPage.document.getElementById("category_id").value = aid;
     parent.toolPage.document.getElementById("category_title").value = atitle;
     var areaid = parent.toolPage.document.getElementById("area_id").value;
     var getStr = "yp.php?option=get_cat&catid=" + aid;
    // var cname = parent.toolPage.document.getElementById("company_id").value;
     if (areaid != "" && areaid != "-1"){
      getStr += "&areaid=" + areaid; 
     }
     //if (cname != ''){getStr +="&cname=" + cname; }
     self.location.replace(getStr);
     
}
function expand_sub(obj, cat_id){
    var real_obj = obj.nextSibling.nextSibling;
    if (real_obj.style.display == "block"){ real_obj.style.display = "none";}
    else{real_obj.style.display = "block";}
}
function js_get_area(val,sid){
 parent.toolPage.document.getElementById("area_id").value = val;
 parent.toolPage.document.getElementById("area_title").value = sid;
 var catid = parent.toolPage.document.getElementById("category_id").value;
 var getStr = "yp.php?option=get_area&areaid=" + val;
 //var cname = parent.toolPage.document.getElementById("company_id").value;
 
 if(catid != "" && catid != "-1"){
  getStr += "&catid=" + catid;
 }
 //if (cname != ''){getStr +="&cname=" + cname; }
 self.location.replace(getStr);
}



function select_onload(){
    var acate_id = parent.toolPage.document.getElementById("category_title").value;
    var aarea_id = parent.toolPage.document.getElementById("area_title").value;
    document.getElementById("cat_select").value = acate_id;
    document.getElementById("area_select").selectedIndex = aarea_id;
}
function banner_select(company_id, company_website){
    myUrl = "";
    if(company_website.search(/http/i) != -1){
        myUrl = company_website;
    }else if(company_website != "-"){
        myUrl = "http://" + company_website;
    }else{
       if(company_id != -1){myUrl = "check_company_type.php?id=" + company_id;}
    }
    if(myUrl){window.open(myUrl,"win1");}
}

function set_ad_id(val){
    document.getElementById("cat_select").value = val;
}

function clear_text(obj){
    obj.value="";
}
function clear_password(obj){
    //obj.type='password';
    obj.value = "";
}
function tv8_init(){
    len_ad = ad_video_array.length;
    len_recommend = recommend_array.length;
    setTimeout("cycle_play()", 1000);

}

function cycle_play(){
    if (cur_recommend + 1 > len_recommend){
      var time_delay = 1;
    } // stop cycle play
    else{
        
        if(default_play){
            if(cur_ad + 1 > len_ad){cur_ad = 0;}  // reset ad video array 
            play_video(ad_video_array[cur_ad], recommend_array[cur_recommend]);
            cur_ad += 1;
            cur_recommend += 1;
        }
    }
}

function user_video(video){
    default_play = "";
    if(cur_ad + 1 > len_ad){cur_ad = 0;}  // reset ad video array 
    //alert(ad_video_array[cur_ad] + " |||  " +  cur_ad + " |||  " +  video )
    play_video(ad_video_array[cur_ad], video);
    
    cur_ad += 1;
}
function play_video(ad_file, video_file){
    scroll(0,100);
    //var path = "http://209.59.198.25/videos/" + val;
    if(checkState()){
waspConfigs0901015241 = null;
waspConfigs0901015241 = new Object();
waspConfigs0901015241.instanceID="0901015241";
waspConfigs0901015241.waspSwf="http://nytv8.com/wimpy_player/wasp.swf";
waspConfigs0901015241.pageColor="000000";
waspConfigs0901015241.fp="http://nytv8.com/index.php";
waspConfigs0901015241.fa= "http://209.59.198.25/videos/" + ad_file;
waspConfigs0901015241.fk="flv";
waspConfigs0901015241.r="MyUzQWglMkZrJTYwMmhuJTdFV0VmRXluOSUyQVUlNURvZHZuRmlpJTVD";
waspConfigs0901015241.v="80";
waspConfigs0901015241.f= "http://209.59.198.25/videos/" + video_file;
waspConfigs0901015241.b="6";
waspConfigs0901015241.me="0";
waspConfigs0901015241.cl="1";
waspConfigs0901015241.h="0";
waspConfigs0901015241.a="0";
waspConfigs0901015241.ph="381";
waspConfigs0901015241.pw="506";
waspConfigs0901015241.waspSkin="sz_1|1|3^sa_1|1|5||663D8F^sf_1|1|||FF8000^sm_1|1|14||FF8000^sv_1|1^sp_1|1|15||FF8000^sb_1||18|F8F8F8|F8F8F8|909090^sg_1|1|||FF8000^st_1|1|||000000^sr_1|1|||FF8000|FFFFFF";
writeWasp(waspConfigs0901015241);
    }
}
function real_view_detail(val){
    var myUrl = "real.php?ccid=" + val;
    self.location.replace(myUrl);
}
function view_detail(val){
    var myUrl = "yp.php?ccid=" + val;
    self.location.replace(myUrl);
}
function checkState(){
    p_state = wasp_amReady_ask("0901015241");
    return(p_state);
}
function m_in(obj){
    obj.src = obj.src.replace('_off', '_on');
}
function m_out(obj){
    obj.src = obj.src.replace('_on.','_off.');
}

function jm_select(id, thumbnail){
    document.getElementById("jm_thumbnail").src = "." + thumbnail;
    change_opacity(10,"jm_detail_panel");
    //document.getElementById("jm_detail_panel").innerHTML = "";
    document.getElementById("ajax_gif").style.display = 'block';
    //setTimeout("startajax(id)",2000);
    setTimeout(function(){startajax(id)},2000);
}
function tr_on(obj){
    obj.className='tr_on';
}
function tr_out(obj){
    obj.className='tr_out';
}
function m_on(obj){obj.className='purple_text';}
function m_off(obj){
    if (obj != ad_post_stock)    obj.className='white_text';
}

function ad_post_img_link(obj,img_Url){
    if (ad_post_stock){
        ad_post_stock.className = "white_text";
    }
    obj.className = "purple_text";
    if(img_Url)document.getElementById("info_img").src = img_Url;
    if(img_Url == "images/text_ad_post_a.png"){
        document.getElementById("ad_post_detail").style.display="block";
    }else{
        document.getElementById("ad_post_detail").style.display="none";
    }
    ad_post_stock = obj;
}

function startajax(id)
{
    //alert("startajax " + id);
var xmlHttp;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  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;
      }
    }
  }
  xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)
      {
        if (xmlHttp.responseText){
            result = xmlHttp.responseText;
            change_opacity(100,"jm_detail_panel");
            document.getElementById("ajax_gif").style.display = 'none';
            document.getElementById("jm_detail_panel").innerHTML =  '' + 
            '<div id="scrollArea1" style="position:absolute;left:270px;top:0px;height:360px;width:15px;border:0px solid #eeeeee;overflow:hidden;text-align:left;">' + 
    '<div style="position:absolute;top:0px;left:2px;height:360px;width:2px;background-color:gray;">' +
    '</div>'+ 
    '<div id="scroller1" style="position:relative;top:0px;width:6px;cursor:pointer;background-color:#331d54;border-top:0px solid #666;border-bottom:0px solid #666;"> '+
    '</div></div>'+
'<div id="container1" style="position:absolute; top:0px;left:0px;width:270px;height:360px;background-color:transparent;overflow:hidden;border:0px solid #aaaaaa; text-align:left">'+
    '<div id="content1" style="position:absolute; width:270px; text-align:left; background-color:transparent;">   '+
            result + 
    '</div>'+
'</div>';
            
            scroller.second_init();
        }
      }
    }
    
  my_url = "get_detail_template.php?id=" + id;
  //alert("myurl  " + my_url);
  xmlHttp.open("GET",my_url,true);
  xmlHttp.send(null);
}
function set_p(val){
    document.getElementById("confirm_option").value = val;
}

function change_opacity(opacity,obj_id)
{
 obj = document.getElementById(obj_id).style;
 obj.opacity = (opacity / 100);
 obj.MozOpacity = (opacity / 100);
 obj.KhtmlOpacity = (opacity / 100);
 obj.filter = "alpha(opacity=" + opacity + ")";
}

