// JavaScript Document
var siteurl = '';
var ipostSiteUrl ='/process/procIpostToday/ipost_act.php';

function dropDownMenu(url){
	
 $("#slide_dropDownTab").toggle(function() {
     $(this).removeClass('dropDownTab');
     $(this).addClass('activeDropDown');
     $("#dropDownMenu").slideDown(100);
     $("#slide_dropDownTab img").attr({src:'/view_design/images/icon/dropDown-upArw.gif'});
     $("#slide_dropDownTab img").attr({width:"14"});
     $("#slide_dropDownTab img").attr({height:"13"});
   }, function() {
     $("#dropDownMenu").slideUp(100);
	 $(this).removeClass('activeDropDown');
	 $(this).addClass('dropDownTab');
	 $("#slide_dropDownTab img").attr({src:'/view_design/images/icon/dropDown-downArw.gif'});
	 $("#slide_dropDownTab img").attr({width:"13"});
	 $("#slide_dropDownTab img").attr({height:"12"});
   });
}

function removeId(id){$("#"+id).remove();}
/*
function json_array(url,param){
	$.ajax({
		type: "POST",
		url: url,
		data: "transport=ajax&"+param,
		dataType:"json",
		success: function(response,jsonp){
			if(typeof(response)!='undefined'){
				for(var i in response){
					$("#"+i).html(response[i]);
				}																	
			}
		}
	});
}
*/

/*
 * Get new captcha code, param id is element id of image     
 */ 
function getNewCaptcha(id,url)
{
    //document.getElementById(id).src = '/images/captcha.png?sid=' + Math.random();		
	document.getElementById(id).src = url+'/components/securimage/securimage_show.php?sid=' + Math.random();		
		return false;
}


function par(arr,return_val){
	var str="";
	if(return_val!=''){
		for(var i in arr){
			str+="<br/>key:: "+i+" val::"+arr[i];
		}
		return str
	}else{
		for(var i in arr){
			document.write("key:: "+i+" value:: "+arr[i]+"<br/>");
		}	
	}
}


function tab_business(indextab){
	if(indextab==1){
		$("#businessEconomic li:last-child").removeClass("active");
		$("#businessEconomic li:first-child").addClass("active");
		$("#economic").css("display","");
		$("#business").css("display","none");
	}else if(indextab == 2){
		$("#businessEconomic li:first-child").removeClass("active");
		$("#businessEconomic li:last-child").addClass("active");
		$("#business").css("display","");
		$("#economic").css("display","none");		
	}
}

$(".webboardPanel ol:not(:eq(0))").hide();
 $(".webboardPanel .contentSwitchTab a").each(function(i) {
	if(i!=0){
		$(this).click(function(){
			/*				   
			$(".webboardPanel .contentSwitchTab li:not(:first)").attr({class:"inActive"});
			$("div .webboardPanel ol").hide();
			$($(this).parent().get(0)).attr({class:"active"});
			$("div .webboardPanel ol").eq(i-1).show();
			*/
			$(".webboardPanel .contentSwitchTab li:not(:first)").removeClass();
			$(".webboardPanel .contentSwitchTab li:not(:first)").addClass("inActive");
			$("div .webboardPanel ol").hide();
			$($(this).parent().get(0)).removeClass();
			$($(this).parent().get(0)).addClass("active");
			$("div .webboardPanel ol").eq(i-1).show();
		});
	}
 });
 
$("#submitComment a").click(function(){Vsubmit();});
function Vsubmit(){
	if(document.getElementById('comment').value =='')
	{
		$("#vlidate_comment span").remove();
		$("#vlidate_comment").append("<span class='err'>กรุณากรอกแสดงความคิดเห็น !!!</span>");
		return false;
	}

	if(document.getElementById('acceptPrivacy').checked===true){
		if(goProcessFacebook())
		{
			document.frm_comment.submit();
			return true;
		}else
			return false;
	}else{
		$("#vlidate_comment span").remove();
		$("#vlidate_comment").append("<span class='err'>กรุณากดยอมรับเงื่อนไข !!!</span>");
		return false;
	}
}

function setHomepage()
{
 if (document.all)
    {
        document.body.style.behavior='url(#default#homepage)';
  			document.body.setHomePage('http://www.posttoday.com');
    }
    else if (window.sidebar)
    {
    if(window.netscape)
    {
         try
   {  
            netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");  
         }  
         catch(e)  
         {  
    alert("this action was aviod by your browser,if you want to enable,please enter about:config in your address line,and change the value of signed.applets.codebase_principal_support to true");  
         }
    } 
    var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components. interfaces.nsIPrefBranch);
    prefs.setCharPref('browser.startup.homepage','http://www.posttoday.com');
 }
}

