function $V(obj){
return document.getElementById(obj).value;	
}


function getCheckedValue(radioObj) {
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}

function Createanother(){
	  showclose("form","result");
}
function savedesktop(urlval){
str= "http://sleep.fm/" + urlval + ".url" ;//document.getElementById('txtresult').value

document.getElementById('savedesk').href=str;
//window.open ("http://www.javascript-coder.com","mywindow");	
}
function ShowURL(){
	/*
	{type {1-3} {1 digit}}
 {m-f {1 digit}}
 {timezone {3 digit}}
 {Locid -10 digit String}
  -1 is interpreted as 0 or 1 denote negative
  
  
  */

	if($V('txtzipcode') ==""){
	alert("Please enter a Valid Zip code")	;
	return;
	}
	
	var txt;
	txt=$V('txtzipcode') + getCheckedValue(document.frmshowme.alarmtype) + getCheckedValue(document.frmshowme.voicetype)  ;
	savedesktop(txt);
	
	document.getElementById('txtresult').value="http://sleep.fm/" + txt +".m3u";


  showclose("box_result","box_form");
  
  document.getElementById("txtresult").select();

	return false;
}

function ShowURL1(){

  showclose("box_result1","box_form");
  
  document.getElementById("txtresult").select();

	return false;
}



function ShowURL2(){

  showclose("box_result2","box_form");
  
  document.getElementById("txtresult").select();

	return false;
}

function ShowURL3(){

  showclose("box_result3","box_form");
  
  document.getElementById("txtresult").select();

	return false;
}

function ShowURL4(){

  showclose("box_result4","box_form");
  
  document.getElementById("txtresult").select();

	return false;
}

function ShowURL5(){

  showclose("box_result5","box_form");
  
  document.getElementById("txtresult").select();

	return false;
}

function ShowURL6(){

  showclose("box_result6","box_form");
  
  document.getElementById("txtresult").select();

	return false;
}

function ShowURL7(){

  showclose("box_result7","box_form");
  
  document.getElementById("txtresult").select();

	return false;
}

function ShowURL8(){

  showclose("box_result8","box_form");
  
  document.getElementById("txtresult").select();

	return false;
}


function ShowURL9(){

  showclose("box_result9","box_form");
  
  document.getElementById("txtresult").select();

	return false;
}

function ShowURL10(){

  showclose("box_result10","box_form");
  
  document.getElementById("txtresult").select();

	return false;
}

function ShowURL11(){

  showclose("box_result11","box_form");
  
  document.getElementById("txtresult").select();

	return false;
}

function ShowURL12(){
	
  showclose("box_result12","box_form");
  
  document.getElementById("txtresult").select();

	return false;
}

function ShowURL13(){
	
  showclose("box_result13","box_form");
  
  document.getElementById("txtresult").select();

	return false;
}

function ShowURL14(){
	
  showclose("box_result14","box_form");
  
  document.getElementById("txtresult").select();

	return false;
}

function ShowURL15(){

  showclose("box_result15","box_form");
  
  document.getElementById("txtresult").select();

	return false;
}

function ShowURL16(){

  showclose("box_result16","box_form");
  
  document.getElementById("txtresult").select();

	return false;
}

function ShowURL17(){

  showclose("box_result17","box_form");
  
  document.getElementById("txtresult").select();

	return false;
}

function ShowURL18(){

  showclose("box_result18","box_form");
  
  document.getElementById("txtresult").select();

	return false;
}

function ShowURL19(){
	
  showclose("box_result19","box_form");
  
  document.getElementById("txtresult").select();

	return false;
}

function ShowURL20(){
	
  showclose("box_result20","box_form");
  
  document.getElementById("txtresult").select();

	return false;
}

function ShowURL21(){

  showclose("box_result21","box_form");
  
  document.getElementById("txtresult").select();

	return false;
}

function ShowURL22(){

  showclose("box_result22","box_form");
  
  document.getElementById("txtresult").select();

	return false;
}

function ShowURL23(){
	
  showclose("box_result23","box_form");
  
  document.getElementById("txtresult").select();

	return false;
}

function ShowURL24(){

  showclose("box_result24","box_form");
  
  document.getElementById("txtresult").select();

	return false;
}

function ShowURL25(){
	
  showclose("box_result25","box_form");
  
  document.getElementById("txtresult").select();

	return false;
}

function ShowURL26(){

  showclose("box_result26","box_form");
  
  document.getElementById("txtresult").select();

	return false;
}

function showclose(divshow,divclose){
	document.getElementById(divshow).style.display="block";
	document.getElementById(divclose).style.display="none";
}


function copytoclipboard(){
	
if(window.clipboardData){ var r=clipboardData.setData('Text',$V('txtresult')); alert("Copied to Clipboard");} 
else
	alert("Unable to access Clipboard"); 	
}
function gettimezoneval(obj){
	var str=$V(obj);
	
	var code=str.substr(0,1)
	if(code =="+")
		buffer="0"
	else
		buffer="1"

	if ( str.length == 3)
		buffer=buffer + str.substr(1);
	else
		buffer=buffer + "0" + str.substr(1);
		
		return buffer;
		
		
		
}
