
// check what platform user using to show certain css for mac
// fixed the scrolling problem with flash file on top of the transparent bg
function detect_user_platform() {
	if(navigator.userAgent.indexOf('Mac') != -1){
		// PERSONAL PROFILE SECTION
		if (document.getElementById('bio-border-cont')) {
			document.getElementById('bio-border-cont').className="bio-border-cont-mac";
		}
		if (document.getElementById('bio-username')) {
			document.getElementById('bio-username').className="bio-username-mac";
		}
		if (document.getElementById('bio-badge-cont')) {
			document.getElementById('bio-badge-cont').className="bio-badge-cont-mac";
		}
		if (document.getElementById('bio-control-cont')) {
			document.getElementById('bio-control-cont').className="bio-control-cont-mac";
		}

		// START ASSIGNING CSS CLASS FOR INDIVIDUAL MODULE IN MAC
		if(document.all) { //IE
			var allDiv1 = document.getElementsByTagName("DIV");
			var allDiv2 = document.getElementsByTagName("DIV");
		} else { //FF
			var allDiv1 = document.getElementById("profile-col_1").getElementsByTagName("DIV");
			var allDiv2 = document.getElementById("profile-col_2").getElementsByTagName("DIV");
		}

		// LEFT COLUMN
		for(var i=0; i < allDiv1.length; i++ ) {
			if (allDiv1[i].className == "indiv-module-container") {
				allDiv1[i].className = "indiv-module-container-mac";
			}
			if (allDiv1[i].className == "profile-zone-container") {
				allDiv1[i].className = "profile-zone-container-mac";
			}
		}

		// RIGHT COLUMN
		for(var i=0; i < allDiv2.length; i++ ) {
			if (allDiv2[i].className == "indiv-module-container") {
				allDiv2[i].className = "indiv-module-container-mac";
			}
			if (allDiv2[i].className == "profile-zone-container") {
				allDiv2[i].className = "profile-zone-container-mac";
			}
		}
		// END ASSIGNING CSS CLASS FOR INDIVIDUAL MODULE IN MAC

		// SHOW PROFILE SECTION
		if (document.getElementById('show-border-cont')) {
			document.getElementById('show-border-cont').className="show-border-cont-mac";
		}
		if (document.getElementById('show-name')) {
			document.getElementById('show-name').className="show-name-mac";
		}
		if (document.getElementById('showLabel-url')) {
			document.getElementById('showLabel-url').className="showLabel-url-mac";
		}
		if (document.getElementById('show-control-cont')) {
			document.getElementById('show-control-cont').className="show-control-cont-mac";
		}
		if (document.getElementById('show-summary-cont')) {
			document.getElementById('show-summary-cont').className="show-summary-cont-mac";
		}
	}
}

function submitToModule(params,method){
	new Ajax.Updater('profile-zone' + zoneId + '-display',
					 location.protocol+'//'+location.host+'/myprofile/mods/'+ partFile[document.getElementById('part_id').value] +'.php',
					 { method:'post', parameters:params} );
}

function submitToInput(keyId,zoneId,partId,edit,modId,qString,method){
	params = 'key_id=' + keyId + '&zone_id=' + zoneId + '&part_id=' + partId + '&edit=' + edit + '&module_id=' + modId + '&' + qString + '&modfile='+ partFile[partId] +'&action=input';
	document.getElementById('profile-zone' + modId + '-feature').value = partId;
	new Ajax.Updater('profile-zone' + modId + '-display',
					 location.protocol+'//'+location.host+'/myprofile/load_module.php',
					 { method:method, parameters:params} );
}

function loadModule(keyId,zoneId,partId,edit,modId,action,partFile){
	params = 'module_id=' + modId + '&key_id=' + keyId + '&zone_id=' + zoneId + '&part_id=' + partId + '&edit=' + edit + '&modfile=' + partFile + '&action=' + action;
	new Ajax.Updater('profile-zone'+modId+'-display',
					 location.protocol+'//'+location.host+'/myprofile/load_module.php',
				     { method:'get', parameters:params,evalScripts:true} );
}

function addHidden(fieldName,fieldVal){
	element = Builder.node('input',{id:fieldName,type:'hidden',value:fieldVal});
	$('profileParams').appendChild(element);
}

function mod_loadjs(){
	jsFiles =mod_loadjs.arguments;

	for(i=0; i<jsFiles.length; i++){
		s = document.createElement('script');
		s.src = jsFiles[i];
		document.getElementsByTagName('head').item(0).appendChild(s);
	}
}

/*
function changeTransparent() {
	if(document.all) { //IE
		var allDiv1 = document.getElementsByTagName("DIV");
		var allDiv2 = document.getElementsByTagName("DIV");
	} else { //FF
		var allDiv1 = document.getElementById("profile-col_1").getElementsByTagName("DIV");
		var allDiv2 = document.getElementById("profile-col_2").getElementsByTagName("DIV");
	}

	// LEFT COLUMN
	for(var i=0; i < allDiv1.length; i++ ) {
		if (allDiv1[i].className == "module-bgColor") {
			allDiv1[i].className = "module-transparent";
		}
	}

	// RIGHT COLUMN
	for(var i=0; i < allDiv2.length; i++ ) {
		if (allDiv2[i].className == "module-bgColor") {
			allDiv2[i].className = "module-transparent";
		}
	}
}
*/

<!--
var $keystrokes = "";
var $eastereggcode = "38 38 40 40 37 39 37 39 66 65";

function podshow_keystrokes($event){
	//ie only
	$keycode = $event.keyCode;
	$keystrokes = $keystrokes + $keycode + " ";
	$match = $keystrokes.indexOf($eastereggcode);
	if($match > -1){
		document.body.style.backgroundImage='url(/images/10718dr171hs7fu.gif)';
		document.body.style.backgroundAttachment='fixed';
		document.body.style.backgroundRepeat='repeat';
		document.body.style.backgroundColor='transparent';
		document.getElementById('body-white-container').style.backgroundColor='transparent';

		changeTransparent();

		$keystrokes = "";
	}
}

function reveal(){
	document.write($keystrokes);
}
//-->



function changeSheets(chooseColor) {

	var chooseStyle=new Array();

	chooseStyle[0]="/css/podshow_gray.css";
	chooseStyle[1]="/css/podshow_blue.css";
	chooseStyle[2]="/css/podshow_orange.css";
	chooseStyle[3]="/css/podshow_purple.css";
	chooseStyle[4]="/css/podshow_pink.css";
	chooseStyle[5]="/css/podshow_red.css";
	chooseStyle[6]="/css/podshow_green.css";
	chooseStyle[7]="/css/podshow_black.css";

	document.getElementById("podshowCSS").href=chooseStyle[chooseColor];
	$('tmpl_css').value = chooseStyle[chooseColor];
}

//updated by K.C. 7/2006
function previewBackground(action){
	bgData = prepBackground();

	if((bgData['BgImg'] == undefined || bgData['BgImg'] == "") &&
	   (bgData['bgColor'] == undefined || bgData['bgColor'] == "") &&
	   (bgData['headerImg'] == undefined || bgData['headerImg'] == "") &&
	   (bgData['color'] == undefined || bgData['color'] == "")){
		if(action == undefined || action != "save"){
			alert("There is nothing to preview.");
		}
	} else {
		if(bgData['headerImg'] != undefined && bgData['headerImg'] != ""){
			document.getElementById('custom-header').src = bgData['headerImg'];
			document.getElementById('custom-header').width = 734;
		}
		if(bgData['bgTrans'] == 'Y'){
			document.getElementById('body-white-container').style.backgroundColor = 'transparent';
			transContainer();
		} else {
			document.getElementById('body-white-container').style.backgroundColor = '';
		}
		if(bgData['BgImg'] != undefined && bgData['BgImg'] != ""){ //background img being assigned
			document.body.style.backgroundImage='url('+ bgData['BgImg'] +')';
			document.body.style.backgroundAttachment = bgData['bgFixed'];
			document.body.style.backgroundRepeat = bgData['bgRepeat'];
			document.body.style.backgroundPosition = bgData['bgPosition'];
		} else { //no background img assigned
			if(bgData['bgColor'] != "undefined" && bgData['bgColor'] != ""){ //bgcolor being selected
				document.body.style.backgroundImage = 'url()';
			}
		}
		if(bgData['bgColor'] != "undefined" && bgData['bgColor'] != ""){
			document.body.style.backgroundColor = '#' + bgData['bgColor'];
		}
		if(bgData['color'] != "undefined" && bgData['color'] != ""){
			document.body.style.color = '#' + bgData['color'];
		}
	}
}

var bg_name = "site-container-bg";
var no_bg_name = "site-container-no-bg";
var header_name = "headerShadow-bg";
var no_header_name = "headerShadow-no-bg";
var footer_name = "footerShadow-bg";
var no_footer_name = "footerShadow-no-bg";

function transContainer() {
	/* REMOVE WHITE BODY BACKGROUND */
	$('body-white-container').style.backgroundColor='transparent';

	/* REMOVE BORDER SHADOWS */
	var allDiv = document.getElementsByTagName("DIV");
	var bg_flag = false;
	var bg_name_len = bg_name.length;
	
	var header_flag = false;
	var header_name_len = header_name.length;

	var footer_flag = false;
	var footer_name_len = footer_name.length;

	for(var i=0; i < allDiv.length; i++ ) {
		if (allDiv[i].className.substr(0, bg_name_len) == bg_name) {
			allDiv[i].className = no_bg_name + allDiv[i].className.substr(bg_name_len);
			bg_flag = true;
		}
		if (allDiv[i].className.substr(0, header_name_len) == header_name) {
			allDiv[i].className = no_header_name + allDiv[i].className.substr(header_name_len);
			header_flag = true;
		}
		if (allDiv[i].className.substr(0, footer_name_len) == footer_name) {
			allDiv[i].className = no_footer_name + allDiv[i].className.substr(footer_name_len);
			footer_flag = true;
		}
		if(bg_flag && footer_flag && header_flag) break;
	}
	/* MODULE BAR TRANSPARENCY */
	changeTransparent();
}

//updated by K.C. 7/2006
function prepBackground(){
	bgData = Array();

	if($('background-attachment').checked == true){
		bgData['bgFixed'] = 'fixed';
	} else {
		bgData['bgFixed'] = 'scroll';
	}

	if($('background-transparent').checked == true){
		bgData['bgTrans'] = 'Y';
	} else {
		bgData['bgTrans'] = 'N';
	}
	bgData['BgImg'] = $('background-image').value.strip();
	bgData['bgRepeat'] = $('background-repeat').value;
	bgData['bgPosition'] = $('background-position').value;
	bgData['bgColor'] = $('background-color').value.strip();
	bgData['color'] = $('color').value.strip();
	bgData['headerImg'] = $('headerImage').value.strip();
	return bgData;
}

function saveBackground(bgData){
	if(bgData == undefined){
		bgData = prepBackground();
	}

	params =  'background-image='       + bgData['BgImg'];
	params += '&background-attachment=' + bgData['bgFixed'];
	params += '&background-position='   + bgData['bgPosition'];
	params += '&background-repeat='     + bgData['bgRepeat'];
	params += '&background-color='		+ bgData['bgColor'];
	params += '&color='					+ bgData['color'];
	params += '&headerImage='			+ bgData['headerImg'];
	params += '&transparent='			+ bgData['bgTrans'];
	params += '&key_id='				+ $('key_id').value;
	params += '&edit='			    	+ $('edit').value;
	params += '&save_bg=1';

	new Ajax.Request(location.protocol+'//'+location.host+'/myprofile/includes/save_bg.php',
					 { method:'post', parameters:params} );

	switchColorBg('color');
	previewBackground("save");
}

function changeHeader(theHeader) {
	var chooseHeader=new Array();	
	
	chooseHeader[0]="/images/PS_banner_flamingTire.jpg";
	chooseHeader[1]="/images/PS_banner_orange.jpg";
	chooseHeader[2]="/images/PS_banner_helicopter.jpg";
	chooseHeader[3]="/images/PS_banner_japan.jpg";
	chooseHeader[4]="/images/PS_banner_music.jpg";
	chooseHeader[5]="/images/PS_banner_trees.jpg";
	chooseHeader[6]="/images/PS_banner_butterflies.jpg";
	chooseHeader[7]="/images/PS_banner_stinkingShoes.jpg";
	chooseHeader[8]="/images/PS_banner_blues.jpg";
	chooseHeader[9]="/images/PS_banner_floraFauna.jpg";
	chooseHeader[10]="/images/PS_banner_whiteFlower.jpg";
	chooseHeader[11]="/images/PS_banner_oldSchool.jpg";
	chooseHeader[12]="/images/PS_banner_transistor.jpg";
	chooseHeader[13]="/images/PS_banner_orangeCrush.jpg";
	chooseHeader[14]="/images/PS_banner_yoPanda.gif";
	chooseHeader[15]="/images/PS_banner_pmale.jpg";
	chooseHeader[16]="/images/PS_banner_organic.gif";
	chooseHeader[17]="/images/PS_banner_curvyLeaves.gif";
	chooseHeader[18]="/images/PS_banner_partyDudes.jpg";
	chooseHeader[19]="/images/PS_banner_japanBoard.jpg";
	chooseHeader[20]="/images/PS_banner_oneWay.jpg";
	
	$('custom-header').src = chooseHeader[theHeader];
	$('headerImage').value = location.protocol+'//'+location.host+chooseHeader[theHeader];
}

function changeBackground(bckgrn) {
	var chooseBackground=new Array();

	chooseBackground[0]="/images/buttons.jpg";
	chooseBackground[1]="/images/dollarm.jpg";
	chooseBackground[2]="/images/flower.jpg";
	chooseBackground[3]="/images/grass.jpg";
	chooseBackground[4]="/images/marymekio.jpg";
	chooseBackground[5]="/images/monsters.jpg";
	chooseBackground[6]="/images/moonscape.jpg";
	chooseBackground[7]="/images/podshow.jpg";
	chooseBackground[8]="/images/punk_boy_rocker.jpg";
	chooseBackground[9]="/images/punk_girl_1.jpg";
	chooseBackground[10]="/images/punk_girl_boots.jpg";
	chooseBackground[11]="/images/swirl.jpg";
	chooseBackground[12]="/images/vw_andy.jpg";
	chooseBackground[13]="/images/white_flower.jpg";
	chooseBackground[14]="/images/yellow_grass.jpg";
	chooseBackground[15]="/images/highheel_shoes.gif";
	chooseBackground[16]="/images/japan_flowers.gif";
	chooseBackground[17]="/images/stinking_shoes.gif";
	chooseBackground[18]="/images/skateboard_dude.gif";
	chooseBackground[19]="/images/butterfly.gif";
	chooseBackground[20]="/images/goth_rocker.gif";
	chooseBackground[21]="/images/babealicious.gif";
	chooseBackground[22]="/images/Surfers1.jpg";
	chooseBackground[23]="/images/Tokyo.jpg";
	chooseBackground[24]="/images/NYC1.jpg";
	chooseBackground[25]="/images/podshow_hyphy.jpg";
	chooseBackground[26]="/images/Rock.jpg";
	chooseBackground[27]="/images/blues.jpg";

	//re-set all related options to default background image settings (by: K.C. 7/2006)
	document.body.style.backgroundImage = 'url('+ chooseBackground[bckgrn] +')';
	$('background-image').value = location.protocol+'//'+location.host+chooseBackground[bckgrn];
	document.body.style.backgroundAttachment = 'fixed';
	$('background-attachment').checked = true;
	document.body.style.backgroundRepeat='repeat';
	$('background-repeat').selectedIndex = 2;
	$('background-position').selectedIndex = 0;
	document.body.style.backgroundColor = 'transparent';
	$('background-transparent').checked = true;

	transContainer();
}

/* Revert back to default settings when user chooses "restore default"
 * By: K.C. 7/2006
 */
function removeDesign() {
	var agree = "Are you sure you want to restore the default settings?";

	if(confirm(agree)){
		//remove the color schemes design
		document.getElementById("podshowCSS").href="";
		//remove background color
		removeBgColor();
		//remove font color
		removeFontColor();
		//remove background image
		removeBgImg();
		//remove header image
		removeHeaderImg();
		//remove color template
		clearTempOutput();
		changeSheets('0');
		//save the settings to DB
		saveTemplate();
		saveBackground();
	}
}

/* Reverts back to the previously saved image
 */
function cancelBackground() {
	document.body.style.backgroundImage = '';
	document.body.style.backgroundAttachment = '';
	document.body.style.backgroundRepeat = '';
	document.body.style.backgroundColor = '';
}

/* Revert back to default setting when user remove the background image
 * By: K.C. 7/2006
 */
function removeBgImg(){
	var bgImg = $('background-image').value.strip();
	var bgColor = $('background-color').value.strip();
	if(bgImg != undefined && bgImg != ""){
		document.getElementById('body-white-container').style.backgroundColor='#fff';
		if(bgColor != undefined && bgColor != ""){
			document.body.style.backgroundColor = '#' + bgColor;
			document.body.style.backgroundImage = 'url()';
			document.body.style.backgroundAttachment = '';
			document.body.style.backgroundRepeat = '';
		} else {
			if (Ps.product == 'uk') {
				document.body.style.backgroundImage = 'url()';
				document.body.style.backgroundColor = '#cc0000';
			} else {
				document.body.style.backgroundImage = 'url(/images/bg_main.gif)';
				document.body.style.backgroundColor = '';
			}
			document.body.style.backgroundAttachment = 'fixed';
			document.body.style.backgroundRepeat = 'repeat-x';
		}
		$('background-image').value = '';
		$('background-attachment').checked = false;
		$('background-transparent').checked = false;
		$('background-repeat').selectedIndex = 0;
		$('background-position').selectedIndex = 0;
	}
}

/* Revert back to default setting when user remove the header image
 * By: K.C. 7/2006
 */
function removeHeaderImg(){
	var hdImg = $('headerImage').value.strip();
	if(hdImg != undefined && hdImg != ""){
		$('custom-header').src = "/images/spacer.gif";
		$('custom-header').removeAttribute("width");
		$('custom-header').removeAttribute("height");
		$('headerImage').value = '';
	}
}

/* Revert back to default setting when user remove the background color
 * By: K.C. 7/2006
 */
function removeBgColor(){
	var bgImg = $('background-image').value.strip();
	var bgColor = $('background-color').value.strip();
	if(bgColor != undefined && bgColor != ""){
		if(bgImg == undefined || bgImg == ""){
			document.body.style.backgroundImage = 'url(/images/bg_main.gif)';
		}
		document.body.style.backgroundColor = '';
		$('background-color').value = '';
		$('background-color').style.background = '';
	}
	resetPickerPosition('background-color');
}

/* Revert back to default setting when user remove the font color
 * By: K.C. 7/2006
 */
function removeFontColor(){
	var fontColor = $('color').value.strip();
	if(fontColor != undefined && fontColor != ""){
		document.body.style.color = '';
		$('color').value = '';
		$('color').style.background = '';
	}
	resetPickerPosition('color');
}

// PUT BACK THE MODULE HEADER COLOR
function changeTransparent() {
	if(document.all) { //IE
		var allDiv1 = document.getElementsByTagName("DIV");
		var allDiv2 = document.getElementsByTagName("DIV");
	} else { //FF
		var allDiv1 = document.getElementById("profile-col_1").getElementsByTagName("DIV");
		var allDiv2 = document.getElementById("profile-col_2").getElementsByTagName("DIV");
	}

	// LEFT COLUMN MODULE
	for(var i=0; i < allDiv1.length; i++ ) {
		if (allDiv1[i].className == "module-transparent") {
			allDiv1[i].className = "module-bgColor";
		}
	}

	// RIGHT COLUMN MODULE
	for(var i=0; i < allDiv2.length; i++ ) {
		if (allDiv2[i].className == "module-transparent") {
			allDiv2[i].className = "module-bgColor";
		}
	}
}