//
function coupon_site_tag_type_change(select_value,coupon_id){
    if(select_value == '1'){
        $('tags_'+coupon_id).style.display = 'block';
    }else{
        $('tags_'+coupon_id).style.display='none';
    }
}

conn = true;
function submit_site_coupon_form_modify(coupon_id){
    var coupon_tag_type = $('coupon_tag_type_'+coupon_id).value
    var tag_names = $('coupon_tag_coupons_'+coupon_id).value
    alert(tag_names);
    if(coupon_tag_type==1){
        new Ajax.Request('/coupon_check_tag_exists_option?tag_names='+tag_names, {method:'get',asynchronous: false, onComplete:function(response){
                var res = response.responseText
                alert(res);
                if(res!="ok"){
                    var con = window.confirm(res+"       Do you want to create ... ?")
                    conn = con;
                }else{conn=true;}
            } });
    }else{conn = true;}
    return conn;
}

function validator_coupon(form){
    value = form.submit_coupon_coupon_title.value;
    if(value.length<5 || value.length>80){
        alert("the title must between 5 and 80");
        return false;
    }else{
        form.submit();
        return true;
    }
}

function request_coupon_stars(coupon_id , star ){
    new Ajax.Request("/site/live_coupons/add_star?id="+coupon_id+"&star="+star,{asynchronous:true, evalScripts:true});
}

function request_open_description(coupon_id){
    $("desc"+ coupon_id ).toggle();
}
 
var isExist = {};
var isHide = {};
var mark = {};


//function submit_site_comment_form(comment_form,coupon_id){
//  var options = [];
//  //options = comment_form['comment[comment_type]'].options;
//  //options = comment_form.comment_comment_type.options ;
//  alert(comment_form);
//  alert(comment_form.getElementsByTagName("select")[0]);
//  options = comment_form.getElementsByTagName("select")[0].options;
//  for(var i=0; i<options.length; i++){
//    if(options[i].value==0 && options[i].selected){
//      if(comment_form.comment_description.value==""){
//        alert("comment should not be empty.");
//        return false;
//      }
//    }
//  } 
//  comment_params = Form.serialize(comment_form)
//  new Ajax.Request('/create_comment?'+comment_params, {method:'post', onComplete:function(response){
//      res = response.responseText
//      if (res.length < 60){
//        alert(res); 
//      }
//    } });
// mark[coupon_id]=3;
// request_new_comment(coupon_id,0);
//}

//function display_comment_invalid(comment_form,coupon_id){
//  var options = [];
//  //options = comment_form.comment_comment_type.options ;
//  options = comment_form['comment[comment_type]'].options;
//  for(var i=0; i<options.length; i++){
//    if(options[i].value==2 && options[i].selected==true){
//            $('site_comment_invalid_'+coupon_id).show();
//    }
//   else{$('site_comment_invalid_'+coupon_id).hide();}
//  }
//}

function submit_valid_vote(coupon_id, valid_count){
    new Ajax.Request("/submit_valid_vote?coupon_id="+coupon_id+"&valid_count="+valid_count, {method:'post', asynchronous:true, evalScripts:true});
}

function submit_invalid_vote(coupon_id, invalid_count){
    new Ajax.Request("/submit_invalid_vote?coupon_id="+coupon_id+"&invalid_count="+invalid_count, {method:'post', asynchronous:true, evalScripts:true});
}

function request_new_comment(coupon_id,sign,valid_count,invalid_count){
    if(sign == 1){
        submit_valid_vote(coupon_id, valid_count);
    }
    else if(sign == 2){    
        submit_invalid_vote(coupon_id, invalid_count);      
    }    
    $("create_comments_" + coupon_id).hide();
    if(isExist[coupon_id] != true)
    {create_comment_html(coupon_id,sign );
        isExist[coupon_id] = true;
        $("new_comment_" + coupon_id).show();
        isHide[coupon_id] = false;
        set_different_for_new_comment(coupon_id,sign);
    }
    else if(isHide[coupon_id] == true)
    {$("new_comment_" + coupon_id).show();
        isHide[coupon_id] = false;
        set_different_for_new_comment(coupon_id,sign);
    }
    else if(mark[coupon_id]==sign)
    {$("new_comment_" + coupon_id).hide();
        isHide[coupon_id] = true;
        control_show_comments(coupon_id,sign);
    }
    else 
    {set_different_for_new_comment(coupon_id,sign);
    }
    mark[coupon_id]=sign;
    var comment_form = document.getElementById("site_comment_form_"+coupon_id+"_id");
    comment_form.comment_description.value = "";
    comment_form.comment_invalid_cause.value = 0;
    //document['site_comment_form_'+coupon_id].comment_description.value = "";
    //document['site_comment_form_'+coupon_id].comment_invalid_cause.value = 0;
}

/*function create_comment_html(coupon_id,sign){
    var div_new_comment = document.getElementById("new_comment_"+coupon_id);
    div_new_comment.appendChild(document.getElementById('site_coupon_template').cloneNode(true));
    var comment_form =  div_new_comment.getElementsByTagName("form")[0];
    comment_form.id="site_comment_form_"+coupon_id+"_id";
    comment_form.name="site_comment_form_"+coupon_id;
    comment_form.getElementsByTagName("div")[0].id = "title_"+coupon_id;
    comment_form.getElementsByTagName("input")[0].value = coupon_id;
    comment_form.getElementsByTagName("div")[6].id = "site_comment_invalid_"+coupon_id;
    var comment_type = comment_form.getElementsByTagName("select")[0];
    comment_type.onchange = function(){
        var options = [];
        // options = comment_form.comment_comment_type.options ;
        //options = comment_form['comment[comment_type]'].options;
        options = comment_type.options;
        for(var i=0; i<options.length; i++){
            if(options[i].value==2 && options[i].selected==true){
                $('site_comment_invalid_'+coupon_id).show();
            }
            else{$('site_comment_invalid_'+coupon_id).hide();}
        }
    };
    var submit_comment = comment_form.getElementsByTagName("input")[1];
    submit_comment.onclick = function(){
        var options = [];
        options = comment_type.options;
        for(var i=0; i<options.length; i++){
            if(options[i].value==0 && options[i].selected){
                if(comment_form.comment_description.value==""){
                    alert("comment should not be empty.");
                    return false;
                }
            }
        } 
        comment_params = Form.serialize(comment_form)
        new Ajax.Request('/create_comment?'+comment_params, {method:'post', onComplete:function(response){
                res = response.responseText
                if (res.length < 60){
                    alert(res); 
                }
            } });
        mark[coupon_id]=3;
        comment_form.comment_description.value = "";
        comment_form.comment_invalid_cause.value = 0;
    };
    document.getElementById("site_coupon_template").style.display="";
}*/

function create_comment_html(coupon_id,sign){
    var div_new_comment = document.getElementById("new_comment_"+coupon_id);
    var site_coupon_template_div = document.getElementById('site_coupon_template').cloneNode(true);
    site_coupon_template_div.id = 'site_coupon_template' + coupon_id;
    site_coupon_template_div.style.display="";
    div_new_comment.appendChild(site_coupon_template_div);
    var comment_form =  div_new_comment.getElementsByTagName("form")[0];
    comment_form.id="site_comment_form_"+coupon_id+"_id";
    comment_form.name="site_comment_form_"+coupon_id;
    
    var divs_in_comment_form = comment_form.getElementsByTagName("div");
    for(var i=0; i < divs_in_comment_form.length; i++){        
        if(divs_in_comment_form[i].className == "for_comment_captcha"){
            var coment_captcha_div = divs_in_comment_form[i];
        }
    }    
    coment_captcha_div.id = "coment_captcha_div_for_coupon_" + coupon_id;
    
    var voted_input = comment_form.getElementsByTagName("input")[1];
    voted_input.id = "voted_"+coupon_id;
    if(sign == 0){
        voted_input.value = 'no';}
    else if(sign == 1 || sign == 2 ){
        voted_input.value = 'yes';}
    comment_form.getElementsByTagName("input")[0].value = coupon_id;
    comment_form.getElementsByTagName("div")[1].id = "site_comment_invalid_"+coupon_id;
    var comment_type = comment_form.getElementsByTagName("select")[0];
    comment_type.onchange = function(){
        var options = [];
        // options = comment_form.comment_comment_type.options ;
        //options = comment_form['comment[comment_type]'].options;
        options = comment_type.options;
        for(var i=0; i<options.length; i++){
            if(options[i].value==2 && options[i].selected==true){
                $('site_comment_invalid_'+coupon_id).show();
            }
            else{$('site_comment_invalid_'+coupon_id).hide();}
        }
    };
    var submit_comment = comment_form.getElementsByTagName("input")[2];
    submit_comment.onclick = function(){
        var options = [];
        options = comment_type.options;
        for(var i=0; i<options.length; i++){
            if(options[i].value==0 && options[i].selected){
                if(comment_form.comment_description.value==""){
                    alert("comment should not be empty.");
                    return false;
                }
            }
        } 
        comment_type.disabled=false;    /*comment_type.disabled=true is for display , at the time of submit we should enable comment_type */
        comment_params = Form.serialize(comment_form)
        new Ajax.Request('/create_comment?'+comment_params, {method:'post', onComplete:function(response){
                res = response.responseText
                if (res.length < 60){
                    alert(res); 
                }
            } });
        mark[coupon_id]=3;
        //        comment_form.comment_comment_type.value = 0;
        //        $('site_comment_invalid_'+coupon_id).hide();
        //        comment_form.comment_description.value = "";
        //        comment_form.comment_invalid_cause.value = 0;   
        //        $('voted_'+coupon_id).value='no';      
    };
    var cancel_comment = comment_form.getElementsByTagName("input")[3];
    cancel_comment.onclick = function(){
        $("new_comment_" + coupon_id).hide();
        isHide[coupon_id] = true; 
        //        comment_form.comment_comment_type.value = 0;
        //        $('site_comment_invalid_'+coupon_id).hide();
        //        comment_form.comment_description.value = "";
        //        comment_form.comment_invalid_cause.value = 0;
    }
    //    document.getElementById("site_coupon_template").style.display="";
}


function set_different_for_new_comment(coupon_id,sign){
    var comment_form = document.getElementById("site_comment_form_"+coupon_id+"_id");
    set_default_select_by_value(comment_form ,sign);
    set_invalid_cause(coupon_id,sign);
    set_voted(coupon_id,sign);
    //set_title(coupon_id,sign);
    control_show_comments(coupon_id,sign);
}

function  set_voted(coupon_id,sign){
    if(sign == 0)
        $("voted_"+coupon_id).value = "no";
    else
        $("voted_"+coupon_id).value = "yes";
}

function set_invalid_cause(coupon_id,sign){
    if(sign == 2)
        $("site_comment_invalid_"+coupon_id).show();
    else
        $("site_comment_invalid_"+coupon_id).hide();
}

function set_title(coupon_id,sign){
    var title_comment = document.getElementById('title_'+coupon_id);
    if(sign==2)    
        if(document.all)
            title_comment.innerText = "Coupon did not work!";
    else
        title_comment.textContent = "Coupon did not work!"; 
    else if(sign==1)
        if(document.all)
            title_comment.innerText = "Coupon worked!";
    else
        title_comment.textContent = "Coupon worked!";
    else
        if(document.all)
            title_comment.innerText = "New Comment";
    else
        title_comment.textContent = "New Comment";
}

function set_default_select_by_value(comment_form, default_value) {  
    var comment_type = comment_form.getElementsByTagName("select")[0];
    for (var i = 0; i < comment_type.options.length; i++) {        
        if (comment_type.options[i].value == default_value) {        
            comment_type.options[i].selected = true;           
            break;        
        }        
    }   
    if(default_value == 0)
        comment_type.disabled = false ;  
    else
        comment_type.disabled = true ;  
}  

//function control_show_comments(coupon_id,sign){
//    if(sign==0 && isExist[coupon_id]==true && isHide[coupon_id]==false)
//        request_opencoupon_comments(coupon_id);
//    else
//        $("comments_" + coupon_id).hide();
//}

function control_show_comments(coupon_id){
    if(isExist[coupon_id]==true && isHide[coupon_id]==false)
        request_opencoupon_comments(coupon_id);
    else
        $("comments_" + coupon_id).hide();
}

var loadedCommentDiv = {}
function request_opencoupon_comments(coupon_id){
    //    if(loadedCommentDiv[coupon_id]!=1) {
    //        new Ajax.Request("/coupon_comments?coupon_id="+coupon_id,{asynchronous:true, evalScripts:true}); 
    //        loadedCommentDiv[coupon_id] = 1;
    //    }
    $("comments_" + coupon_id).show();   
}

function validator_search_keyword(){
    if ($('keyword').value == ""){
        alert("please input the key word");
        $('keyword').focus();
        return false;
    }
    else if($('keyword').value.length < 2 ){
        alert("please input a longer key word");
        $('keyword').focus();
        return false;
    }
    return true;
}

//function cp_to_clipboard(text) {        //the old method ,now we use copy_to_clipboard()
//    var flashcopier = 'flashcopier';
//    if(!document.getElementById(flashcopier)) {
//        var divholder = document.createElement('div');
//        divholder.id = flashcopier;
//        document.body.appendChild(divholder);
//    }
//    document.getElementById(flashcopier).innerHTML = '';
//    var divinfo = '<embed src="/images/liveclipboard.swf" FlashVars="liveclipboard='+encodeURIComponent(text)+'" width="0" height="0" type="application/x-shockwave-flash"></embed>';
//    document.getElementById(flashcopier).innerHTML = divinfo;
//}



/***********************************************
 * Cool DHTML tooltip script II- Â© Dynamic Drive DHTML code library (www.dynamicdrive.com)
 * This notice MUST stay intact for legal use
 * Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
 ***********************************************/

var offsetfromcursorX=12 //Customize x offset of tooltip
var offsetfromcursorY=10 //Customize y offset of tooltip

var offsetdivfrompointerX=30 //Customize x offset of tooltip DIV relative to pointer image
var offsetdivfrompointerY=6 //Customize y offset of tooltip DIV relative to pointer image. Tip: Set it to (height_of_pointer_image-1).

document.write('<div id="dhtmltooltip"></div>') //write out tooltip DIV
document.write('<img id="dhtmlpointer" src="/images/tooltip_arrow.gif">') //write out pointer image

var ie=document.all
var ns6=document.getElementById && !document.all
var enabletip=false
if (ie||ns6)
    var tipobj=document.all? document.all["dhtmltooltip"] : document.getElementById? document.getElementById("dhtmltooltip") : ""

var pointerobj=document.all? document.all["dhtmlpointer"] : document.getElementById? document.getElementById("dhtmlpointer") : ""

function ietruebody(){
    return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function ddrivetip(thetext, thewidth, thecolor, thetextcolor){
    if (ns6||ie){
        if (typeof thewidth!="undefined") tipobj.style.width=thewidth+"px"
        if (typeof thecolor!="undefined" && thecolor!="") tipobj.style.backgroundColor=thecolor
        if (typeof thetextcolor!="undefined" && thetextcolor!="") tipobj.style.color=thetextcolor
        tipobj.innerHTML=thetext
        enabletip=true
        return false;
    }
    return true;
}

function positiontip(e){
    if (enabletip){
        var nondefaultpos=false
        var curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft;
        var curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop;
        //Find out how close the mouse is to the corner of the window
        var winwidth=ie&&!window.opera? ietruebody().clientWidth : window.innerWidth-20
        var winheight=ie&&!window.opera? ietruebody().clientHeight : window.innerHeight-20

        var rightedge=ie&&!window.opera? winwidth-event.clientX-offsetfromcursorX : winwidth-e.clientX-offsetfromcursorX
        var bottomedge=ie&&!window.opera? winheight-event.clientY-offsetfromcursorY : winheight-e.clientY-offsetfromcursorY

        var leftedge=(offsetfromcursorX<0)? offsetfromcursorX*(-1) : -1000

        //if the horizontal distance isn't enough to accomodate the width of the context menu
        if (rightedge<tipobj.offsetWidth){
            //move the horizontal position of the menu to the left by it's width
            tipobj.style.left=curX-tipobj.offsetWidth+"px"
            nondefaultpos=true
        }
        else if (curX<leftedge)
            tipobj.style.left="5px"
        else{
            //position the horizontal position of the menu where the mouse is positioned
            tipobj.style.left=curX+offsetfromcursorX-offsetdivfrompointerX+"px"
            pointerobj.style.left=curX+offsetfromcursorX+"px"
        }

        //same concept with the vertical position
        if (bottomedge<tipobj.offsetHeight){
            tipobj.style.top=curY-tipobj.offsetHeight-offsetfromcursorY+"px"
            nondefaultpos=true
        }
        else{
            tipobj.style.top=curY+offsetfromcursorY+offsetdivfrompointerY+"px"
            pointerobj.style.top=curY+offsetfromcursorY+"px"
        }
        tipobj.style.visibility="visible"
        if (!nondefaultpos)
            pointerobj.style.visibility="visible"
        else
            pointerobj.style.visibility="hidden"
    }
}

function hideddrivetip(){
    if (ns6||ie){
        enabletip=false
        tipobj.style.visibility="hidden"
        pointerobj.style.visibility="hidden"
        tipobj.style.left="-1000px"
        tipobj.style.backgroundColor=''
        tipobj.style.width=''
    }
}

document.onmousemove=positiontip

/***********************************************
 * Cool DHTML tooltip script END
 ***********************************************/  


///***********************************************
// * Fixed ToolTip script- © Dynamic Drive (www.dynamicdrive.com)
// * This notice MUST stay intact for legal use
// * Visit http://www.dynamicdrive.com/ for full source code
// ***********************************************/
//		
//var tipwidth='150px' //default tooltip width
//var tipbgcolor='lightyellow'  //tooltip bgcolor
//var disappeardelay=250  //tooltip disappear speed onMouseout (in miliseconds)
//var vertical_offset="0px" //horizontal offset of tooltip from anchor link
//var horizontal_offset="-3px" //horizontal offset of tooltip from anchor link
//
///////No further editting needed
//
//var ie4=document.all
//var ns6=document.getElementById&&!document.all
//
//if (ie4||ns6)
//    document.write('<div id="fixedtipdiv" style="visibility:hidden;width:'+tipwidth+';background-color:'+tipbgcolor+'" ></div>')
//
//function getposOffset(what, offsettype){
//    var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
//    var parentEl=what.offsetParent;
//    while (parentEl!=null){
//        totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
//        parentEl=parentEl.offsetParent;
//    }
//    return totaloffset;
//}
//
//
//function showhide(obj, e, visible, hidden, tipwidth){
//    if (ie4||ns6)
//        dropmenuobj.style.left=dropmenuobj.style.top=-500
//    if (tipwidth!=""){
//        dropmenuobj.widthobj=dropmenuobj.style
//        dropmenuobj.widthobj.width=tipwidth
//    }
//    if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover")
//        obj.visibility=visible
//    else if (e.type=="click")
//        obj.visibility=hidden
//}
//
//function iecompattest(){
//    return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
//}
//
//function clearbrowseredge(obj, whichedge){
//    var edgeoffset=(whichedge=="rightedge")? parseInt(horizontal_offset)*-1 : parseInt(vertical_offset)*-1
//    if (whichedge=="rightedge"){
//        var windowedge=ie4 && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15
//        dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
//        if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
//            edgeoffset=dropmenuobj.contentmeasure-obj.offsetWidth
//    }
//    else{
//        var windowedge=ie4 && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
//        dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
//        if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure)
//            edgeoffset=dropmenuobj.contentmeasure+obj.offsetHeight
//    }
//    return edgeoffset
//}
//
//function fixedtooltip(menucontents, obj, e, tipwidth){
//    if (window.event) event.cancelBubble=true
//    else if (e.stopPropagation) e.stopPropagation()
//    clearhidetip()
//    dropmenuobj=document.getElementById? document.getElementById("fixedtipdiv") : fixedtipdiv
//    dropmenuobj.innerHTML=menucontents
//
//    if (ie4||ns6){
//        showhide(dropmenuobj.style, e, "visible", "hidden", tipwidth)
//        dropmenuobj.x=getposOffset(obj, "left")
//        dropmenuobj.y=getposOffset(obj, "top")
//        dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+"px"
//        dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+"px"
//    }
//}
//
//function hidetip(e){
//    if (typeof dropmenuobj!="undefined"){
//        if (ie4||ns6)
//            dropmenuobj.style.visibility="hidden"
//    }
//}
//
//function delayhidetip(){
//    if (ie4||ns6)
//        delayhide=setTimeout("hidetip()",disappeardelay)
//}
//
//function clearhidetip(){
//    if (typeof delayhide!="undefined")
//        clearTimeout(delayhide)
//}
///***********************************************
// * Fixed Cool DHTML tooltip script END
// ***********************************************/  



function operate_homepage_top_coupons(operation_name) {
    if(operation_name == 'show') {
        document.cookie = "top_coupons=show";
    }else{
        var exptime = new Date();
	exptime.setDate(exptime.getDate()+70000);
	document.cookie = "top_coupons=hide; expires=" + exptime.toGMTString();
    }
    Element.toggle('homepage_top_coupons_show');
    Element.toggle('homepage_top_coupons_hide');
}

function memorize_user_behavior_on_homepage_top_coupons() {
    cookies = document.cookie.split(";");
    for(var i=0; i< cookies.length; i++){
        if(cookies[i].indexOf("top_coupons")){
            var top_coupons = cookies[i].split("=")[1];
        }
    }
    if(top_coupons == 'show'){
        Element.show('homepage_top_coupons_show');
        Element.hide('homepage_top_coupons_hide');
    }else{
        Element.hide('homepage_top_coupons_show');
        Element.show('homepage_top_coupons_hide');
    }
}

function limitText(limitField, limitCount, limitNum) {
    /*
    if (limitField.value.length > limitNum) {
        limitField.value = limitField.value.substring(0, limitNum);
    } else {
        if (limitCount != null){
            limitCount.value = limitNum - limitField.value.length;
        }
		
    }//*/
}

function check_submit_sign_up(){
    var i = 0
    //    var user_name = document.getElementsByTagName("input")[i + 1];
    var e_mail    = document.getElementById("sign_up_email");
    var password1 = document.getElementById("sign_up_pass1");
    var password2 = document.getElementById("sign_up_pass2");
    // check user name
    //    if(user_name.value=="")
    //    {alert("user name should not be blank");
    //     return false;}
    //    if(user_name.value.length<4)
    //    {alert("user name is too short");
    //     return false;}  
    //    if(user_name.value.length>20)
    //    {alert("user name is too long");
    //     return false;}
    //    if(!new RegExp("[_a-zA-Z]","g").test(user_name.value.split("")[0]))
    //    {alert("user name shoule be beginned with letter");
    //     return false ;}
    //    if(!new RegExp("^[a-zA-Z0-9_]*$","g").test(user_name.value))
    //    {alert("user name shoule be letters , numbers and underline");
    //      return false; }
    // check email
    if(e_mail.value=="")
    {alert("email is blank");
        return false;}
    if(e_mail.value.length>50)
    {alert("email is too long");
        return false;}
    if(!new RegExp("^[\\w._]+@\\w+\.(\\w+\.){0,3}\\w{2,4}$","g").test(e_mail.value.replace(/-|\//g,"")))
    {alert("wrong email format");
        return false;}
    //check  password
    if(password1.value=="")
    {alert("password should not be blank");
        return false;}
    if(password1.value.length<6)
    {alert("password is too short");
        return false;}
    if(password1.value.length>20)
    {alert("password is too long");
        return false;}
    if(password2.value==null||password2.value!=password1.value)
    {alert("the password and the confirmation are different");
        return false;}
    return true;
}

function toggle_submit_button_by_privacy(submit_button){
    if(submit_button.disabled == false){
        submit_button.disabled=true;    
        submit_button.style.color = 'gray';
    }else{
        submit_button.disabled=false;  
        submit_button.style.color = '#416B06';
    }
    return true;
}

function add_src_type_for_link(obj,type){
    //    var src_sym = obj.href.indexOf('?') >= 0 ? '&' : '?';
    //    obj.href = obj.href + src_sym + 'src=' + type;
    //    obj.onmousedown = function(){return true;}
    return true;
}
/***********************/ 
/**Start ZeroClipboard**/ 
/***********************/ 
var clip = null;
// setup single ZeroClipboard object for all our elements
clip = new ZeroClipboard.Client();
ZeroClipboard.setMoviePath( '/images/ZeroClipboard.swf' );
clip.setHandCursor( true );
clip.addEventListener('mouseOver', function(client) {
    ddrivetip('Click to copy and open site...', 190, '#fff','#cc6600');
});
clip.addEventListener('mouseOut', function(client) {
    hideddrivetip('');
});
    
function openlink(link) {
    window.open(link);
}

function flashChecker()
{
    var hasFlash=0;         //�Ƿ�װ��flash
    var flashVersion=0;     //flash�汾
    if(document.all){       //�ж��Ƿ�Ϊie��ie4���ϣ�
        var swf = new ActiveXObject('ShockwaveFlash.ShockwaveFlash');
        if(swf) {
            hasFlash=1;
            VSwf = swf.GetVariable("$version");
            flashVersion = parseInt(VSwf.split(" ")[1].split(",")[0]);
        }
    }
    else{
        if (navigator.plugins && navigator.plugins.length > 0){
            var theswf = navigator.plugins["Shockwave Flash"];
            if (theswf){
                hasFlash=1;
                var words = theswf.description.split(" ");
                for (var i = 0; i < words.length; ++i)
                {
                    if (isNaN(parseInt(words[i]))) continue;
                    flashVersion = parseInt(words[i]);
                }
            }
        }
    }
    return {f:hasFlash,v:flashVersion};
}

function copy_to_clipboard(text, link, object) {
    var fls = flashChecker();
    if(fls.f==1 && fls.v>8){
        // set the clip text to our innerHTML
        clip.setText(text);
        //if this is the first time , create it ,if not , reposition the movie over our element
        if (clip.div) {
            //clip.receiveEvent('mouseout', null);
            clip.reposition(object);               
        }
        else clip.glue(object);
        //clip.receiveEvent('mouseover', null);
        var our_link = link;
        clip.setEventListener('mouseup', function(client) { 
            openlink(our_link);
            hideddrivetip('');
        });
    }
}
/***********************/ 
/**End ZeroClipboard****/ 
/***********************/ 

var CommentJS = {    
    remove_all_comment_captchas_by_class_name : function(captcha_container_class_name){
        var all_divs = document.getElementsByTagName("div");
        for(var i=0; i < all_divs.length; i++){
            if(all_divs[i].className == captcha_container_class_name){
                all_divs[i].innerHTML = '';
            }
        }        
    }
}
