// JavaScript Document
//Function to choose how many topics are show
function ShowTopics(Show, FID){

   	strShow = escape(Show.options[Show.selectedIndex].value);
   	document.cookie = "TS=" + strShow

   	if (Show != "") self.location.href = "forum_topics.php?FID=" + FID + "&PN=1";
	return true;
}

//Function to jump to another forum
function ForumJump(URL) {
	
	if (URL.options[URL.selectedIndex].value != "") self.location.href = URL.options[URL.selectedIndex].value;	
	return true;
}

function OpenAlbum(iAlbumID) {

 document.getElementById("AID").value = iAlbumID;

	frmForumPosts.action = "galbum.asp";

	frmForumPosts.submit(); 
}

function CheckForm() {
	var errorMsg = '';

	//Check for message
	if (document.forms.frmAddMessage.message.value==''){
		errorMsg += '\n\tMessage \t\t- Enter a Message to post';
	}

	//If there is aproblem with the form then display an error
	if (errorMsg != ''){
		msg = '_______________________________________________________________\n\n';
		msg += 'The form has not been submitted because there are problem(s) with the form.\n';
		msg += 'Please correct the problem(s) and re-submit the form.\n';
		msg += '_______________________________________________________________\n\n';
		msg += 'The following field(s) need to be corrected: -\n';

		errorMsg += alert(msg + errorMsg + '\n\n');
		return false;
	}

	//Reset the submition action
	document.forms.frmAddMessage.action = 'forum_post_message.php?PN=1'
	document.forms.frmAddMessage.target = '_self';
	document.forms.frmAddMessage.Submit.disabled=true;
	return true;
}

function openWin(theURL,winName,features) {
  	window.open(theURL,winName,features);
}

function RateIt(iEntity)
{
	var strUrl = "forum_grating.php"
	var arrScores = document.all("score");
	var iScore = 0;
	for(i=0;i<arrScores.length;i++)	{
		if(arrScores[i].checked)
			iScore = i;
	}
	var s = new String();
	strUrl += "?EntityName=Topic_ID&Entity_ID=" + iEntity + "&score=" + iScore
	window.open(strUrl,'vote','width=150,height=100');
}





function toggle_visible(dibObj, height1, height2, active) {
        
	if(active == 1) {                
       divPlusOne(dibObj, height1, height2);                
            
    } else if(active == 0){                    
        divMinusOne(dibObj, height1, height2);
            
    }
        
}

function divMinusOne(dibObj, height1, height2) 
{            
    height1 = parseInt(document.getElementById(dibObj).style.height.replace(" px", ""));
	if(height1 >= 1) 
	{            
        height1 = parseInt(document.getElementById(dibObj).style.height.replace(" px", "")) - 1;
        document.getElementById(dibObj).style.height=height1 + 'px';
        
		window.setTimeout('divMinusOne("' + dibObj + '", ' + height1 + ', ' + height2 + ')', 0.01);
    } 
	else 
	{            
       //document.getElementById(dibObj).style.visibility="hidden";            
    }
            
} 

function divPlusOne(dibObj, height1, height2) 
{            
    if(height1 <= height2) 
	{            
        document.getElementById(dibObj).style.visibility="visible";   
        
		height1 = parseInt(document.getElementById(dibObj).style.height.replace(" px", "")) + 1;
        document.getElementById(dibObj).style.height=height1 + 'px';        
                
        window.setTimeout('divPlusOne("' + dibObj + '", ' + height1 + ', ' + height2 + ')', 0.01);                
    }    
}


function renew_account_show_product(packID)
{
	var l = all_pack_ids.length;
	for (x = 0; x < l; x++)
	{
		var t2 = document.getElementById("pack_products_div_" + all_pack_ids[x]);
		if (packID == all_pack_ids[x])
		{
			var is_product = document.getElementById("pack_products_" + packID).value;			
			if (is_product == 1)
			{
				t2.style.visibility = "visible";	
				//t2.style.height='100px';
				renew_account_show_product_order(packID);
				toggle_visible("pack_products_div_" + packID, 0, products_div_height[all_pack_ids[x]], 1);
				//alert(products_div_height[all_pack_ids[x]]);
			}
			else
			{
				t2.style.height='0px';
				t2.style.visibility = "hidden";	
				//t2.style.height='100px';
			}
		}
		else
		{
			t2.style.height='0px';
			t2.style.visibility = "hidden";			
			
			var t22 = document.getElementById("pack_products_order_div_" + all_pack_ids[x]);
			t22.style.visibility = "hidden";			
			
			//toggle_visible("pack_products_div_" + all_pack_ids[x], 1, 0);
		}
	}	
}

function renew_account_show_product_order(packID)
{
	var is_product_checked = false;
	var radioObj = document.RenewAccountForm["pack_id_product_" + packID];
	if(radioObj)
	{
		var radioLength = radioObj.length;
		if(radioLength == undefined)
		{
			if(radioObj.checked)
				is_product_checked = true;
		}
		for(var i = 0; i < radioLength; i++) {
			if(radioObj[i].checked) {
				is_product_checked = true;
			}
		}
	}
	
	var t2 = document.getElementById("pack_products_order_div_" + packID);
	if (is_product_checked)
	{		
		t2.style.visibility = "visible";		
	}
	else
	{
		t2.style.visibility = "hidden";		
	}
}

function renew_account_products_height()
{
	var l = all_pack_ids.length;
	for (x = 0; x < l; x++)
	{
		var t2 = document.getElementById("pack_products_div_" + all_pack_ids[x]);
		var h = t2.offsetHeight;
		products_div_height[all_pack_ids[x]] = h;
	}
}



function my_profile_delete_my_profile_confirm(redirectUrl)
{
	var agree=confirm("Are you sure you want to delete your profile ?");
    if (agree)
    	window.location.href = redirectUrl;
}
