	function popupFS(url) {
		//if(fs==1) { setFS = 'yes'; } else { setFS = 'no'; }
		var is_iDev = $.cookie("is_iDev");
		if (is_iDev=='iDev') {
			getURL = url.replace("/issues", "/issues3"); 	
		} else {
			getURL = url.replace("/issues", "/issues2"); 	
		}
		params  = 'width='+screen.width;
		params += ',height='+screen.height;
		params += ',top=0,left=0'
		params += ',fullscreen=yes';
		
		newwin=window.open(getURL,'windowname4', params);
		if (window.focus) { newwin.focus(); }
		return false;
	}

/*
	function nuWin(url) {
		var w = screen.width-(screen.width*.20);
		var h = screen.height-(screen.height*.20);
		
		var scroll = 'yes';
		var winL = (screen.width - w) / 2;
		var winT = (screen.height - h-100) / 2;
		winprops = 'height='+h+',width='+w+',top='+winT+',left='+winL+',scrollbars='+scroll+',resizable';
		var randNum=Math.floor(Math.random()*10001);
		var winName = 'cem_'+randNum;
		win = window.open(url, winName, winprops);
		if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
	}
*/
	function replaceIt(page) {
				location.replace(page);
	}
	/*====================================================================*/
	function open_link_homepage(page){
				var open_window = $.cookie("open_window");
				if(open_window === null) { 
							popupFS(page);
				} else {
					if(open_window=='same_window') { 
						//  window.location='/issues'+url; 
									if(linkType=='location') {
										location.replace(page); 
									} else { 
											window.location=page; 
									}
					} else if(open_window=='new_window_fs') { 
						//  nuWin(url)('/issues'+url);
							popupFS(page); 
					} else {
						// popupFS('/issues'+url);
							popupFS(page);
					}
			}
	}
	/*====================================================================*/

	function open_link(page){
				var open_window = $.cookie("open_window");
				if(open_window === null) { 
								// alert('url = '+window.location);
							//	getURL = page.replace("http://cem.giovanniproductions.com", ""); 	
						if((window.location=='http://www.cem-az.com/') || (window.location=='http://www.cem-az.com/index.php') || (window.location=='http://cem-az.com/') || (window.location=='http://cem-az.com/index.php') ) {
									popupFS(page);
						} else {
								openprompt(page);
						}
				} else {
					if(open_window=='same_window') { 
						//  window.location='/issues'+url; 
									if(linkType=='location') {
										location.replace(page); 
									} else { 
											window.location=page; 
									}
							// location.replace(page); 
					/*} else if(open_window=='same_window_fs') { 
						//  window.location='/issues'+url; 
							window.location=page; 
					} else if(open_window=='new_window') { 
						//  popupFS('/issues2'+url); 
							nuWin(page);*/
					} else if(open_window=='new_window_fs') { 
						//  nuWin(url)('/issues'+url);
							popupFS(page); 
					} else {
						// popupFS('/issues'+url);
							popupFS(page);
					}
			}
	}
	/*====================================================================*/

	function openprompt(url){
		getURL = url.replace("http://www.cem-az.com", ""); 	
		getURL = getURL.replace("http://cem-az.com", ""); 	
		var temp = {
			state0: {
			html:'<p>How would you like the Magazine to open?</p>'
								+'<div class="field marL10">&nbsp;&nbsp;&nbsp;<input type="radio" name="choose_window" id="same_window" value="same_window" class="radioinput" /><label for="same_window">&nbsp;Normally, in the Same Window</label></div>'
								+'<div class="field marL10">&nbsp;&nbsp;&nbsp;<input type="radio" name="choose_window" id="new_window_fs" value="new_window_fs" class="radioinput" /><label for="new_window_fs">&nbsp;In a New Window, Full Screen<span class="red">*</span></label><br />&nbsp;&nbsp;&nbsp;&nbsp; <span class="red"> *recommended</span><p>After making a selection, please click on the original link to the Magazine and it will open in the manner you have selected.</p></div>',
							//	+'<div class="field marL10">&nbsp;&nbsp;&nbsp;<input type="radio" name="choose_window" id="new_window_fs" value="new_window_fs" class="radioinput" /><label for="new_window_fs">&nbsp;In a New Window, Full Screen<span class="red">*</span></label><br />&nbsp;&nbsp;&nbsp;&nbsp; <span class="red"> *recommended</span></div>',
							//	+'<div class="field"><input type="radio" name="choose_window" id="new_window" value="new_window" class="radioinput" /><label for="new_window">In a New Window</label></div>'
							//	+'<div class="field"><input type="radio" name="choose_window" id="same_window_fs" value="same_window_fs" class="radioinput" /><label for="same_window_fs">In the Same Window, Full Screen</label></div>'
			buttons: { Cancel: false, Finish: true },
			focus: 1,
			submit:function(v,m,f){ 
				if(!v) {
					$.prompt.close();
				} else { // $.prompt.goToState('state1');//go forward
					return true;
				}
					return false; 
				}
			}
		}
		$.prompt(temp,{
			callback: function(v,m,f){
				var str = '';
				$.each(f,function(i,obj){
					str += i + "=" + obj + "&";
				});	
				window.location='?'+str+'submitted=1&link='+getURL;
				}
		});
	}
	/*====================================================================*/

	function openprompt2(url){
		// alert(url);
		// getURL = url.replace("http://cem.giovanniproductions.com/set_preference.php?page=", ""); 	
		// alert(getURL);
		// exit();
		var temp = {
			state0: {
			html:'<p>How would you like the Magazine to open?</p>'
								+'<div class="field marL10">&nbsp;&nbsp;&nbsp;<input type="radio" name="choose_window" id="same_window" value="same_window" class="radioinput" /><label for="same_window">&nbsp;Normally, in the Same Window</label></div>'
								+'<div class="field marL10">&nbsp;&nbsp;&nbsp;<input type="radio" name="choose_window" id="new_window_fs" value="new_window_fs" class="radioinput" /><label for="new_window_fs">&nbsp;In a New Window, Full Screen<span class="red">*</span></label><br />&nbsp;&nbsp;&nbsp;&nbsp; <span class="red"> *recommended</span><p>After making a selection, please click on the original link to the Magazine and it will open in the manner you have selected.</p></div>',
							//	+'<div class="field"><input type="radio" name="choose_window" id="new_window" value="new_window" class="radioinput" /><label for="new_window">In a New Window</label></div>'
							//	+'<div class="field"><input type="radio" name="choose_window" id="same_window_fs" value="same_window_fs" class="radioinput" /><label for="same_window_fs">In the Same Window, Full Screen</label></div>'
			buttons: { Cancel: false, Finish: true },
			focus: 1,
			submit:function(v,m,f){ 
				if(!v) {
					$.prompt.close();
				} else { // $.prompt.goToState('state1');//go forward
					return true;
				}
					return false; 
				}
			}
		}
		$.prompt(temp,{
			callback: function(v,m,f){
				var str = '';
				$.each(f,function(i,obj){
					str += i + "=" + obj + "&";
				});	
				window.location='?'+str+'submitted=1&link='+getURL;
				}
		});
	}

	/*====================================================================*/
	function choice_completed(page,open_window) {
	
		var temp = {
				state0: {
				html:'<p>Thank you. Your choice has been noted and all future links to the Magazine will open in the same manner.</p><br />'
											+'<p>If you would like to change your selection in the future, you can do so at any time by clicking the <a href="/preference.php" style="color:#800000;font-weight:bold">"Change Magazine Viewing Option"</a> link at the bottom of the page.</p><br />'
											+'<p>To continue to the Magazine link you selected originally, <a href="/redirect.php?goto='+page+'">click here</a>.</p>'
											+'<p>The Magazine will open when you click "Finish"</p>',
				buttons: { Finish: true },
					focus: 1,
					submit:function(v,m,f){ 
						if(!v) { 
							$.prompt.close();
						} else if(page!='') {
							if(open_window=='same_window') { 
									// window.location=page; 
									if(linkType=='location') {
										//history.back(-1);
										location.replace(page); 
									} else { 
											window.location=page; 
									}
								/*} else if(open_window=='same_window_fs') { 
									window.location=page; 
								} else if(open_window=='new_window') { 
									nuWin(page);*/
								} else if(open_window=='new_window_fs') { 
									popupFS(page); 
								} else {
									popupFS(page);
								}
									return true;//go forward
								} else {
								return true;//go forward
						}
					}
				}
			}
			$.prompt(temp,{
				callback: function(v,m,f){
 					// var str = '<p><a href="'+link+'" '+target+'>Click Here</a> to open the Magazine<br /></p></p>'+$.prompt.close();
					//$.prompt(str);
					}
			});
	}
/*======================================================================================================================*/
	function change_option(){
		var open_window = $.cookie("open_window");
		var showMsg;
		if(open_window === null) { 
			showMsg = '<p>You do not currently have a preference saved.</p><br />';
		} else if(open_window === 'same_window') { 
			showMsg = '<p>You are currently viewing the Magazine in <br /><strong>"Same Window"</strong> mode</p><br />';
		} else if(open_window === 'new_window_fs') { 
			showMsg = '<p>You are currently viewing the Magazine in <br /><strong>"New Window, Full Screen"</strong> mode</p><br />';
		} else {
			 showMsg = '';
		}
		var temp = {
			state0: {
			html:showMsg+'<p><strong>How would you like the Magazine to open?</strong></p>'
								+'<div class="field marL10">&nbsp;&nbsp;&nbsp;<input type="radio" name="choose_window" id="same_window" value="same_window" class="radioinput" /><label for="same_window">&nbsp;Normally, in the Same Window</label></div>'
								+'<div class="field marL10">&nbsp;&nbsp;&nbsp;<input type="radio" name="choose_window" id="new_window_fs" value="new_window_fs" class="radioinput" /><label for="new_window_fs">&nbsp;In a New Window, Full Screen<span class="red">*</span></label><br />&nbsp;&nbsp;&nbsp;&nbsp; <span class="red"> *recommended</span></div>',
							//	+'<div class="field"><input type="radio" name="choose_window" id="new_window" value="new_window" class="radioinput" /><label for="new_window">In a New Window</label></div>'
						//								+'<div class="field"><input type="radio" name="choose_window" id="same_window_fs" value="same_window_fs" class="radioinput" /><label for="same_window_fs">In the Same Window, Full Screen</label></div>'
			buttons: { Cancel: false, Finish: true },
			focus: 1,
			submit:function(v,m,f){ 
				if(!v) {
					$.prompt.close();
				} else { // $.prompt.goToState('state1');//go forward
					return true;
				}
					return false; 
				}
			}
		}
		$.prompt(temp,{
			callback: function(v,m,f){
				var str = '';
				$.each(f,function(i,obj){
					str += i + "=" + obj + "&";
				});	
				window.location='?'+str+'submitted=1&confirm=1';
				}
		});
	}
	/*====================================================================*/
	function confirm_change(open_window) {
	
		var temp = {
				state0: {
				html:'<p>Thank you. Your choice has been noted and all future links to the Magazine will open in the same manner.</p><br />'
											+'<p>If you would like to change your selection in the future, you can do so at any time by clicking the <a href="/preference.php" style="color:#800000;font-weight:bold">"Change Magazine Viewing Option"</a> link at the bottom of the page.</p>',
				buttons: { Finish: true },
					focus: 1,
					submit:function(v,m,f){ 
						if(!v) { 
							$.prompt.close();
								} else {
								//	alert(open_window);
							 location.replace('/preference.php');
								return true;//go forward
						}
					}
				}
			}
			$.prompt(temp,{
				callback: function(v,m,f){
 					// var str = '<p><a href="'+link+'" '+target+'>Click Here</a> to open the Magazine<br /></p></p>'+$.prompt.close();
					//$.prompt(str);
					}
			});
	}

