// JavaScript Document
//global vars
var BASE_URL = 'http://www.kapanlagi.com';
//global member

function createRequestObject() {
   var ro = null;
   if (typeof XMLHttpRequest != "undefined") {
      ro = new XMLHttpRequest();
   } else {
      try {
         ro = new ActiveXObject("Msxml2.XMLHTTP");
      }
      catch (e) {
         try {
               ro = new ActiveXObject("Microsoft.XMLHTTP");
         }
         catch (e) {
         }
      }
   }
   return ro;
}

var http = createRequestObject();

function getPartner() {}

function getURLParam(strParamName)
{
	var strReturn = "";
	var strHref = window.location.href;

	if ( strHref.indexOf("?") > -1 )
	{
		var strQueryString = strHref.substr(strHref.indexOf("?")).toLowerCase();
		var aQueryString = strQueryString.split("&");
		for ( var iParam = 0; iParam < aQueryString.length; iParam++ )
		{
			if (aQueryString[iParam].indexOf(strParamName + "=") > -1 )
			{
				var aParam = aQueryString[iParam].split("=");
				strReturn = aParam[1];
				break;
			}
		}
	}
	return strReturn;
}

function createCookie(name,value,days)
{
	if (days)
	{
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/; domain=kapanlagi.com";
}

function readCookie(name)
{
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++)
	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name)
{
	createCookie(name,"",-1);
}

function sndReqCelebrities(go, action) 
{
	try
	{
		http.open('post', go);
		http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		http.send(action);

		http.onreadystatechange = function () {
			if(http.readyState == 4) 
			{
				var response = http.responseText;

				if (http.status == 200) 
				{
					var sp = response.split('||');
					//document.getElementById('comment').innerHTML = response;
					document.getElementById('comment').innerHTML = sp[1];
				}
				else 
				{
					alert("ERROR:" + http.status + " Ada masalah pada pengiriman data!");
				}
			}
		}
	}
	catch (e){}
	finally {}
}

function getDataService(go, action, id) 
{
	try
	{
		http.open('post', go);
		http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		http.send(action);

		http.onreadystatechange = function () {
			if(http.readyState == 4) 
			{
				var response = http.responseText;

				if (http.status == 200) 
				{
					document.getElementById(id).innerHTML = response;
				}
				else 
				{
					alert("ERROR:" + http.status + " Ada masalah pada pengiriman data!");
				}
			}
		}
	}
	catch (e){}
	finally {}
}

function sndReqCelebritiesMessage(go, action) 
{
	try
	{
		http.open('post', go);
		http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		http.send(action);

		http.onreadystatechange = function () {
			if(http.readyState == 4) 
			{
				var response = http.responseText;

				if (http.status == 200) 
				{
					document.getElementById('comment_list').innerHTML = response;
				}
				else 
				{
					alert("ERROR:" + http.status + " Ada masalah pada pengiriman data!");
				}
			}
		}
	}
	catch (e){}
	finally {}
}

function sndReqHeadlines(go, action) 
{
	try
	{
		http.open('post', go);
		http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		http.send(action);

		http.onreadystatechange = function () {
			if(http.readyState == 4) 
			{
				var response = http.responseText;

				if (http.status == 200) 
				{
					document.getElementById('headlines').innerHTML = response;
				}
				else 
				{
					alert("ERROR:" + http.status + " Ada masalah pada pengiriman data!");
				}
			}
		}
	}
	catch (e){}
	finally {}
}

function sndReqHeadlinesNew(go, action) 
{
	try
	{
		http.open('post', go);
		http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		http.send(action);

		http.onreadystatechange = function () {
			if(http.readyState == 4) 
			{
				var response = http.responseText;

				if (http.status == 200) 
				{
					document.getElementById('headlines_new').innerHTML = response;
				}
				else 
				{
					alert("ERROR:" + http.status + " Ada masalah pada pengiriman data!");
				}
			}
		}
	}
	catch (e){}
	finally {}
}

function sndReqPreviousNews(go, action) 
{
	try
	{
		http.open('post', go);
		http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		http.send(action);

		http.onreadystatechange = function () {
			if(http.readyState == 4) 
			{
				var response = http.responseText;

				if (http.status == 200) 
				{
					document.getElementById('previousNews').innerHTML = response;
				}
				else 
				{
					alert("ERROR:" + http.status + " Ada masalah pada pengiriman data!");
				}
			}
		}
	}
	catch (e){}
	finally {}
}


function sndReqGaleriIndex(go, action, div)
{
	try
	{
		http.open('post', go);
		http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		http.send(action);

		http.onreadystatechange = function () {
			if(http.readyState == 4) 
			{
				if (http.status == 200) 
				{
					var response = http.responseText;
					document.getElementById(div).innerHTML = response;
				}
				else 
				{
					alert("ERROR:" + http.status + " Ada masalah pada pengiriman data!");
				}
			}
		}
	}
	catch (e){}
	finally {}
}

function sndNewsComment(go, action) 
{
	try
	{
		http.open('post', go);
		http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		http.send(action);

		http.onreadystatechange = function () {
			if(http.readyState == 4) 
			{
				var response = http.responseText;

				if (http.status == 200) 
				{
					document.getElementById('commentNews').innerHTML = response;
				}
				else 
				{
					alert("ERROR:" + http.status + " Ada masalah pada pengiriman data!");
				}
			}
		}
	}
	catch (e){}
	finally {}
}

function statusMember()
{
	var rb;
	
	if (document.frmProfile.status[0].checked == true) 
		rb = document.frmProfile.status[0].value;
	
	if (document.frmProfile.status[1].checked == true)
		rb = document.frmProfile.status[1].value;
	
	if (document.frmProfile.status[2].checked == true)
		rb = document.frmProfile.status[2].value;
	
	if (document.frmProfile.status[3].checked == true)
		rb = document.frmProfile.status[3].value;

	return rb;
}

function sndReqCelebToday(go, action) 
{
	try
	{
		http.open('post', go);
		http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		http.send(action);

		http.onreadystatechange = function () {
			if(http.readyState == 4) 
			{
				var response = http.responseText;

				if (http.status == 200) 
				{
					document.getElementById('seleb_today').innerHTML = response;
				}
				else 
				{
					alert("ERROR:" + http.status + " Ada masalah pada pengiriman data!");
				}
			}
		}
	}
	catch (e){}
	finally {}
}

   function getDataHtmlTemplate(go,id) 
   {
      var httpTpl = null;
      if (typeof XMLHttpRequest != "undefined") {
         httpTpl = new XMLHttpRequest();
      } else {
         try {
            httpTpl = new ActiveXObject("Msxml2.XMLHTTP");
         }
         catch (e) {
            try {
               httpTpl = new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch (e) {
            }
         }
      }
      
      try
      {
         httpTpl.open('post', go);
         //http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
         httpTpl.onreadystatechange = function () {
            if(httpTpl.readyState == 4) 
            {
               var response = httpTpl.responseText;
               if (httpTpl.status == 200) 
               {
                  document.getElementById(id).innerHTML = response;
               }
               else 
               {
                  alert("ERROR:" + httpTpl.status + " Ada masalah pada pengiriman data!");
               }
            }else{
               document.getElementById(id).innerHTML = '<img src="http://img.kapanlagi.com/i/v2/loading.gif" /> loading';   
            }
         }
         httpTpl.send('');
      }
      catch (e){}
      finally {
         return true;   
      }
   }
   
function getIframeHight(){
   //window.alert('Welcome');
   try{   
      parent.document.getElementById('iframeLeft').style.height = window.frames['iframeLeft'].document.getElementById('boxLeftIframe').offsetHeight +"px";
   }catch(e){}
   
   try{   
      parent.document.getElementById('iframeRightXRadio').style.height = window.frames['iframeRightXRadio'].document.getElementById('boxRightXradioIframe').offsetHeight +"px";
   }catch(e){
      //window.alert(e);
   }
   
   try{   
      parent.document.getElementById('iframeRightXRadioFull').style.height = window.frames['iframeRightXRadioFull'].document.getElementById('boxRightRadioFull').offsetHeight +"px";
   }catch(e){
      //window.alert(e);
   }

   try{   
      parent.document.getElementById('iframeRightXWallapaper').style.height = window.frames['iframeRightXWallapaper'].document.getElementById('boxRightXwallpaperIframe').offsetHeight +"px";
   }catch(e){}
   try{   
      parent.document.getElementById('iframeRightEcard').style.height = window.frames['iframeRightEcard'].document.getElementById('boxRightEcardIframe').offsetHeight +"px";
   }catch(e){}
   try{   
      parent.document.getElementById('iframeRightFilm').style.height = window.frames['iframeRightFilm'].document.getElementById('boxRightResFilmIframe').offsetHeight +"px";
   }catch(e){}
   
   try{   
      parent.document.getElementById('iframeRightMusic').style.height = window.frames['iframeRightMusic'].document.getElementById('boxRightResMusicIframe').offsetHeight +"px";
   }catch(e){}
   
   try{   
      parent.document.getElementById('iframeRightPhoto').style.height = window.frames['iframeRightPhoto'].document.getElementById('boxRightPhoto').offsetHeight +"px";
   }catch(e){}
}

function getIframeRightHight(){

   try{      
      parent.document.getElementById('iframeRightFilm').style.height = document.getElementById('boxRightResFilmIframe').offsetHeight + "px";
   }catch(e){}
   
   try{   
      parent.document.getElementById('iframeRightPhoto').style.height = document.getElementById('boxRightPhoto').offsetHeight +"px";
   }catch(e){}
}


function getEqualLeftRight(){
   
   if(document.getElementById('right')){
      var right      = document.getElementById('right').offsetHeight;
      var left       = document.getElementById('left').offsetHeight;
      var leftMain   = document.getElementById('leftMain');
      
      if(right>left)
      {
         var height = right-left;
         leftMain.style.paddingBottom = height+'px';
      }   
   }  

}


function getDataOption() {
	var  opVipAdds;

	if(document.getElementById('vip_adds1').checked)
        {
           opVipAdds = document.getElementById('vip_adds1').value;
        }
        else if(document.getElementById('vip_adds2').checked)
        {
            opVipAdds = document.getElementById('vip_adds2').value;
        }
	
	return opVipAdds;
}

/*
        Create cookie by minutes
*/ 
function createCookie2(name,value,minute)
{
	if (minute)
	{
		var date = new Date();
		date.setTime(date.getTime()+(minute*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/; domain=kapanlagi.com";
}

/*
        set default email from cookie (cookie will deleted where it goes 30 minutes
        to1 = sender
        to2 = email
*/
function setEmailSender(cookie1, cookie2, to1, to2) {
        if (readCookie(cookie1) != null)
        {
                var senderFriend = document.getElementById(to1);
                if (senderFriend) senderFriend.value = readCookie(cookie1);
        }
        if (readCookie(cookie2) != null)
        {
                var emailFriend = document.getElementById(to2);
                if (emailFriend) emailFriend.value = readCookie(cookie2);
        }
}

function togleShow(id){
   var temp = document.getElementById(id);
   if(temp.style.display=='none'){
      temp.style.display='inline';
   }else{
      temp.style.display='none';
   }
}

function sndReqGlobal(go,sendvar,checkLogin,divId,divIdProses,divIdMenu){
   
   var name = "c_member_id";
   //alert(go+sendvar);
   if (readCookie(name) == null && checkLogin=='true'){
      alert("Anda harus login sebagai member terlebih dahulu");
      document.location = BASE_URL;
   }else if(readCookie(name) == null && checkLogin=='trueNoRefresh'){
      alert("Anda harus login sebagai member terlebih dahulu");
   }else{
      try{
         if(http == null){
            var http = createRequestObject();
         }
         http.open('post', go);
         http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
         http.send(sendvar);
         document.getElementById(divIdProses).innerHTML = '<img src="http://img.kapanlagi.com/i/v2/indicator_remembermilk_orange.gif" >';
         http.onreadystatechange = function()
         {
               if(http.readyState == 4){
                  document.getElementById(divIdProses).innerHTML = '&nbsp;';
                  if (http.status == 200){
                     var response = http.responseText;
                     if (response.indexOf('||') != -1){
                        update = new Array;
                        update = response.split('||');
                        switch (update[0]){
                           case "error" :
                              alert(update[1]);
                           break;
                           
                           case "successRefresh" :
                              alert(update[1]);
                              document.location.replace(update[2]);
                           break;
                        
                           case "success" :
                              if (update[1] == 'home') document.location = "http://face.kapanlagi.com/"; //alert(update[1]);
                           break;

                           case "successCange" :
                              alert(update[1]);
                              document.getElementById(divId).innerHTML = update[2];
                           break;
                        }
                     }else if (response.indexOf('<-SEPARATOR->') != -1){
                           update = new Array;
                           update = response.split('<-SEPARATOR->');                           
                           document.getElementById(divIdMenu).innerHTML = update[0];
                           document.getElementById(divId).innerHTML = update[1];
                     }else{
                        document.getElementById(divId).innerHTML = response;
                     }
                  }else{
                     alert("ERROR: " + http.status + " Ada masalah pada pengiriman data!");
                  }
               }
            
         }
      }
      catch(e){}
      finally {}
   }
}



/**
 * SWFObject v1.4.4: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
 *
 * SWFObject is (c) 2006 Geoff Stearns and is released under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 * **SWFObject is the SWF embed script formerly known as FlashObject. The name was changed for
 *   legal reasons.
 */
if(typeof deconcept=="undefined"){var deconcept=new Object();}
if(typeof deconcept.util=="undefined"){deconcept.util=new Object();}
if(typeof deconcept.SWFObjectUtil=="undefined"){deconcept.SWFObjectUtil=new Object();}
deconcept.SWFObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a,_b){if(!document.getElementById){return;}
this.DETECT_KEY=_b?_b:"detectflash";
this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY);
this.params=new Object();
this.variables=new Object();
this.attributes=new Array();
if(_1){this.setAttribute("swf",_1);}
if(id){this.setAttribute("id",id);}
if(w){this.setAttribute("width",w);}
if(h){this.setAttribute("height",h);}
if(_5){this.setAttribute("version",new deconcept.PlayerVersion(_5.toString().split(".")));}
this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion();
if(c){this.addParam("bgcolor",c);}
var q=_8?_8:"high";
this.addParam("quality",q);
this.setAttribute("useExpressInstall",_7);
this.setAttribute("doExpressInstall",false);
var _d=(_9)?_9:window.location;
this.setAttribute("xiRedirectUrl",_d);
this.setAttribute("redirectUrl","");
if(_a){this.setAttribute("redirectUrl",_a);}};
deconcept.SWFObject.prototype={setAttribute:function(_e,_f){
this.attributes[_e]=_f;
},getAttribute:function(_10){
return this.attributes[_10];
},addParam:function(_11,_12){
this.params[_11]=_12;
},getParams:function(){
return this.params;
},addVariable:function(_13,_14){
this.variables[_13]=_14;
},getVariable:function(_15){
return this.variables[_15];
},getVariables:function(){
return this.variables;
},getVariablePairs:function(){
var _16=new Array();
var key;
var _18=this.getVariables();
for(key in _18){_16.push(key+"="+_18[key]);}
return _16;},getSWFHTML:function(){var _19="";
if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){
if(this.getAttribute("doExpressInstall")){
this.addVariable("MMplayerType","PlugIn");}
_19="<embed type=\"application/x-shockwave-flash\" src=\""+this.getAttribute("swf")+"\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\"";
_19+=" id=\""+this.getAttribute("id")+"\" name=\""+this.getAttribute("id")+"\" ";
var _1a=this.getParams();
for(var key in _1a){_19+=[key]+"=\""+_1a[key]+"\" ";}
var _1c=this.getVariablePairs().join("&");
if(_1c.length>0){_19+="flashvars=\""+_1c+"\"";}_19+="/>";
}else{if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");}
_19="<object id=\""+this.getAttribute("id")+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\">";
_19+="<param name=\"movie\" value=\""+this.getAttribute("swf")+"\" />";
var _1d=this.getParams();
for(var key in _1d){_19+="<param name=\""+key+"\" value=\""+_1d[key]+"\" />";}
var _1f=this.getVariablePairs().join("&");
if(_1f.length>0){_19+="<param name=\"flashvars\" value=\""+_1f+"\" />";}_19+="</object>";}
return _19;
},write:function(_20){
if(this.getAttribute("useExpressInstall")){
var _21=new deconcept.PlayerVersion([6,0,65]);
if(this.installedVer.versionIsValid(_21)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){
this.setAttribute("doExpressInstall",true);
this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));
document.title=document.title.slice(0,47)+" - Flash Player Installation";
this.addVariable("MMdoctitle",document.title);}}
if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){
var n=(typeof _20=="string")?document.getElementById(_20):_20;
n.innerHTML=this.getSWFHTML();return true;
}else{if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}}
return false;}};
deconcept.SWFObjectUtil.getPlayerVersion=function(){
var _23=new deconcept.PlayerVersion([0,0,0]);
if(navigator.plugins&&navigator.mimeTypes.length){
var x=navigator.plugins["Shockwave Flash"];
if(x&&x.description){_23=new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));}
}else{try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");}
catch(e){try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
_23=new deconcept.PlayerVersion([6,0,21]);axo.AllowScriptAccess="always";}
catch(e){if(_23.major==6){return _23;}}try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");}
catch(e){}}if(axo!=null){_23=new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));}}
return _23;};
deconcept.PlayerVersion=function(_27){
this.major=_27[0]!=null?parseInt(_27[0]):0;
this.minor=_27[1]!=null?parseInt(_27[1]):0;
this.rev=_27[2]!=null?parseInt(_27[2]):0;
};
deconcept.PlayerVersion.prototype.versionIsValid=function(fv){
if(this.major<fv.major){return false;}
if(this.major>fv.major){return true;}
if(this.minor<fv.minor){return false;}
if(this.minor>fv.minor){return true;}
if(this.rev<fv.rev){
return false;
}return true;};
deconcept.util={getRequestParameter:function(_29){
var q=document.location.search||document.location.hash;
if(q){var _2b=q.substring(1).split("&");
for(var i=0;i<_2b.length;i++){
if(_2b[i].substring(0,_2b[i].indexOf("="))==_29){
return _2b[i].substring((_2b[i].indexOf("=")+1));}}}
return "";}};
deconcept.SWFObjectUtil.cleanupSWFs=function(){if(window.opera||!document.all){return;}
var _2d=document.getElementsByTagName("OBJECT");
for(var i=0;i<_2d.length;i++){_2d[i].style.display="none";for(var x in _2d[i]){
if(typeof _2d[i][x]=="function"){_2d[i][x]=function(){};}}}};
deconcept.SWFObjectUtil.prepUnload=function(){__flash_unloadHandler=function(){};
__flash_savedUnloadHandler=function(){};
if(typeof window.onunload=="function"){
var _30=window.onunload;
window.onunload=function(){
deconcept.SWFObjectUtil.cleanupSWFs();_30();};
}else{window.onunload=deconcept.SWFObjectUtil.cleanupSWFs;}};
if(typeof window.onbeforeunload=="function"){
var oldBeforeUnload=window.onbeforeunload;
window.onbeforeunload=function(){
deconcept.SWFObjectUtil.prepUnload();
oldBeforeUnload();};
}else{window.onbeforeunload=deconcept.SWFObjectUtil.prepUnload;}
if(Array.prototype.push==null){
Array.prototype.push=function(_31){
this[this.length]=_31;
return this.length;};}
var getQueryParamValue=deconcept.util.getRequestParameter;
var FlashObject=deconcept.SWFObject;
var SWFObject=deconcept.SWFObject;

//cekMemberLogin();
//redirectMemberDiv();