var xmlHttp;
function createXMLHttpRequest() {
    if (window.ActiveXObject) {
        xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    } 
    else if (window.XMLHttpRequest) {
        xmlHttp = new XMLHttpRequest();                
    }
}

function checkDesignerAvailable(value,rooturl){
    createXMLHttpRequest();
    var url = rooturl + "?id=" + value;
   	xmlHttp.open("Post", url, true);
    xmlHttp.onreadystatechange = goCallbackAlert;
    xmlHttp.send(null);
}

function forceacitveajax( designerid  ){
    createXMLHttpRequest();
    var url = baseurl + "ajax/forceative.php?id=" + designerid;
   	xmlHttp.open("Post", url, true);
    xmlHttp.onreadystatechange = goCallbackAlert;
    xmlHttp.send(null);
}

function goCallbackAlert() {
    if (xmlHttp.readyState == 4) {
        if (xmlHttp.status == 200) {
            if(xmlHttp.responseText=="0"){
                alert("sorry,you can not add design for this designer now.");
                return false;
            }
			
        }
    }
}

function changeStory(rooturl , id,story,region,school,labels,music,movies,                                 television,books,facebook,myspace,twitter){
    createXMLHttpRequest();
    var url = rooturl + "?type=story&" + "id=" + id +"&story="+story+"&region="+region+"&school="+school+"&labels="+labels+"&music="+music+"&movies="+movies+"&television="+television+"&books="+books+"&facebook="+facebook+"&myspace="+myspace+"&twitter="+twitter;
   	xmlHttp.open("Post", url, true);
    xmlHttp.onreadystatechange = goCallbackAlertUpdate;
    xmlHttp.send(null);
}


function goCallbackAlertUpdate() {
    if (xmlHttp.readyState == 4) {
        if (xmlHttp.status == 200) {
            if(xmlHttp.responseText=="true"){
                alert("update successfully.");
                window.location= window.location;
            }else if(xmlHttp.responseText=="exist"){
                alert("Email address alreay exist.");
                window.location= window.location;
            }
            else{
                 alert("sorry,update failed.");
            }
        }
    }
}


function updatePayPalInfo(rooturl , id, paypalemail,password,name,ssn,email){
    createXMLHttpRequest();
    var url = rooturl + "?type=paypal&" + "id=" + id +"&paypalemail="+paypalemail+ "&password=" + password + "&name=" + name+ "&ssn=" + ssn+ "&email=" + email;
   	xmlHttp.open("Post", url, true);
    xmlHttp.onreadystatechange = goCallbackAlertUpdate;
    xmlHttp.send(null);
}

function updateCheckInfo(rooturl , id, street,city,state,zip,password,name,ssn,email){
    createXMLHttpRequest();
    var url = rooturl + "?type=check&" + "id=" + id +"&street="+street+"&city="+city+"&state="+state+"&zip="+zip+ "&password=" + password + "&name=" + name+ "&ssn=" + ssn+ "&email=" + email;
   	xmlHttp.open("Post", url, true);
    xmlHttp.onreadystatechange = goCallbackAlertUpdate;
    xmlHttp.send(null);
}

function palyvideo(videoid){
    var ajaxurl = baseurl + "moxiemark/changevideo/"+videoid;
    $.ajax({
        type:"post",
        url:ajaxurl,
        success: function(result)
        {
            CIframe.location.reload(CIframe.src);
            var arrresult = result.split("@");
            $('#videotitle').html(arrresult[0]);
            $('#videodesc').html(arrresult[1]);
             $('#morevideohtml').html(arrresult[2]);
            return false;
        },
                                
        error: function(result)
        {
            alert(result.responseText);
        }
    });
   
}